Issues (76)

examples/cdn_get_flux.php (1 issue)

Labels
Severity
1
<?php
2
3
require_once __DIR__ . '/../autoload.php';
4
5
use Qiniu\Auth;
6
use \Qiniu\Cdn\CdnManager;
0 ignored issues
show
The type \Qiniu\Cdn\CdnManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
// 控制台获取密钥:https://portal.qiniu.com/user/key
9
$accessKey = getenv('QINIU_ACCESS_KEY');
10
$secretKey = getenv('QINIU_SECRET_KEY');
11
12
$auth = new Auth($accessKey, $secretKey);
13
$cdnManager = new CdnManager($auth);
14
15
// 获取流量和带宽数据
16
// 参考文档:https://developer.qiniu.com/fusion/api/1230/traffic-bandwidth
17
18
$domains = array(
19
    "javasdk.qiniudn.com",
20
    "phpsdk.qiniudn.com"
21
);
22
23
$startDate = "2020-08-03";
24
$endDate = "2020-08-05";
25
26
//5min or hour or day
27
$granularity = "day";
28
29
list($fluxData, $getFluxErr) = $cdnManager->getFluxData($domains, $startDate, $endDate, $granularity);
30
if ($getFluxErr != null) {
31
    var_dump($getFluxErr);
32
} else {
33
    echo "get flux data success\n";
34
    print_r($fluxData);
35
}
36