require '../vendor/autoload.php';

use Qiniu\Auth;
use \Qiniu\Cdn\CdnManager;

$accessKey = 'xxxxxx';
$secretKey = 'xxxxxx';

$auth = new Auth($accessKey, $secretKey);

$cdnManager = new CdnManager($auth);

$domains = array(
    "xxx.com",
    "qiniu.xxx.com"
);

$region = "china";
$startDate = "2020-02-15";
$endDate = "2020-02-17";

//批量请求访问流量 Top URL
//参考文档:https://developer.qiniu.com/fusion/api/4081/cdn-log-analysis#14

list($topUrlData, $getUrlErr) = $cdnManager->getTopTrafficUrl($domains, $region, $startDate, $endDate);
if ($getUrlErr != null) {
    var_dump($getUrlErr);
} else {
    echo "get cdn top traffic url success\n";
    print_r($topUrlData);
}
    
//getTopTrafficUrl方法。在 src/Qiniu/Cdn/CdnManager.php 中添加即可

public function getTopTrafficUrl(array $domains, $region, $startDate, $endDate){
$req = array();
$req['domains'] = $domains;
$req['region'] = $region;
$req['startDate'] = $startDate;
$req['endDate'] = $endDate;

$url = $this->server . '/v2/tune/loganalyze/toptrafficurl';
$body = json_encode($req);
return $this->post($url, $body);
}