PHP code example of easy-cloud-request / volc

1. Go to this page and download the library: Download easy-cloud-request/volc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

easy-cloud-request / volc example snippets



use EasyCloudRequest\Volc\Gateway;

$type = 'file';
$urls = [
    'your link'
];
$request = new RequestBag(
    'GET',
    // 'https://cdn.volcengineapi.com?Version=2021-03-01&Action=SubmitRefreshTask',
    'https://cdn.volcengineapi.com',
    [
        "Action" => 'SubmitRefreshTask',
        "Version" => '2021-03-01',
        'region' => 'cn-north-1',
        'service' => 'CDN',
    ],
    [],
    [
        "Type" => $type,
        "Urls" => implode('\n', $urls)
    ]
);

$request = new RequestBag(
    'POST',
    'https://cdn.volcengineapi.com',
    [
        "Action" => 'DescribeEdgeTopStatisticalData',
        "Version" => '2021-03-01',
        'region' => 'cn-north-1',
        'service' => 'CDN',
    ],
    [],
    [
        'StartTime' => $startFieldCarbon->getTimestamp(),
        'EndTime' => $endFieldCarbon->getTimestamp(),
        'Domain' => 'www.baidu.com',
        'Item' => 'url',
        'Metric' => 'pv',
    ]
);


use EasyCloudRequest\Volc\Gateway;
use EasyCloudRequest\Core\Support\RequestBag;


$cloud = new SimpleCloud([
    'default' => Gateway::class,
    'gateway' => [
        'volc' => [
            'ak' => 'your ak',
            'sk' => 'your sk',
        ]
    ],
    'http_options' => [
        "http_errors" => false,
        "proxy" => [],
        "verify" => false,
        "timeout" => 120,
        "connect_timeout" => 60,
    ]
]);
$result = $cloud->requests($request);
var_dump($result);