You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
crmeb_php/vendor/qiniu/php-sdk/examples/cdn_get_flux.php

35 lines
786 B

1 year ago
<?php
require_once __DIR__ . '/../autoload.php';
use \Qiniu\Cdn\CdnManager;
$accessKey = getenv('QINIU_ACCESS_KEY');
$secretKey = getenv('QINIU_SECRET_KEY');
$auth = new Qiniu\Auth($accessKey, $secretKey);
$cdnManager = new CdnManager($auth);
//获取流量和带宽数据
//参考文档:http://developer.qiniu.com/article/fusion/api/traffic-bandwidth.html
$domains = array(
"javasdk.qiniudn.com",
"phpsdk.qiniudn.com"
);
$startDate = "2017-08-20";
$endDate = "2017-08-21";
//5min or hour or day
$granularity = "day";
//获取流量数据
list($fluxData, $getFluxErr) = $cdnManager->getFluxData($domains, $startDate, $endDate, $granularity);
if ($getFluxErr != null) {
var_dump($getFluxErr);
} else {
echo "get flux data success\n";
print_r($fluxData);
}