Skip to content

Commit a1d7e51

Browse files
authored
Merge pull request #239 from jemygraw/master
refractor the php sdk to use the v2 uc query api
2 parents 09a10c0 + bc4c0bc commit a1d7e51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1059
-777
lines changed

examples/auth.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/bucket_mgr.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

examples/bucket_mgr_init.php

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/cdn_get_bandwidth.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../autoload.php';
4+
5+
use \Qiniu\Cdn\CdnManager;
6+
7+
$accessKey = getenv('QINIU_ACCESS_KEY');
8+
$secretKey = getenv('QINIU_SECRET_KEY');
9+
10+
$auth = new Qiniu\Auth($accessKey, $secretKey);
11+
$cdnManager = new CdnManager($auth);
12+
13+
//获取流量和带宽数据
14+
//参考文档:http://developer.qiniu.com/article/fusion/api/traffic-bandwidth.html
15+
16+
$domains = array(
17+
"javasdk.qiniudn.com",
18+
"phpsdk.qiniudn.com"
19+
);
20+
21+
$startDate = "2017-08-20";
22+
$endDate = "2017-08-21";
23+
24+
//5min or hour or day
25+
$granularity = "day";
26+
27+
//获取带宽数据
28+
list($bandwidthData, $getBandwidthErr) = $cdnManager->getBandwidthData($domains, $startDate, $endDate, $granularity);
29+
if ($getBandwidthErr != null) {
30+
var_dump($getBandwidthErr);
31+
} else {
32+
echo "get bandwidth data success\n";
33+
print_r($bandwidthData);
34+
}

examples/cdn_get_flux.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../autoload.php';
4+
5+
use \Qiniu\Cdn\CdnManager;
6+
7+
$accessKey = getenv('QINIU_ACCESS_KEY');
8+
$secretKey = getenv('QINIU_SECRET_KEY');
9+
10+
$auth = new Qiniu\Auth($accessKey, $secretKey);
11+
$cdnManager = new CdnManager($auth);
12+
13+
//获取流量和带宽数据
14+
//参考文档:http://developer.qiniu.com/article/fusion/api/traffic-bandwidth.html
15+
16+
$domains = array(
17+
"javasdk.qiniudn.com",
18+
"phpsdk.qiniudn.com"
19+
);
20+
21+
$startDate = "2017-08-20";
22+
$endDate = "2017-08-21";
23+
24+
//5min or hour or day
25+
$granularity = "day";
26+
27+
//获取流量数据
28+
list($fluxData, $getFluxErr) = $cdnManager->getFluxData($domains, $startDate, $endDate, $granularity);
29+
if ($getFluxErr != null) {
30+
var_dump($getFluxErr);
31+
} else {
32+
echo "get flux data success\n";
33+
print_r($fluxData);
34+
}

examples/cdn_get_log_list.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../autoload.php';
4+
5+
use \Qiniu\Cdn\CdnManager;
6+
7+
$accessKey = getenv('QINIU_ACCESS_KEY');
8+
$secretKey = getenv('QINIU_SECRET_KEY');
9+
10+
$auth = new Qiniu\Auth($accessKey, $secretKey);
11+
$cdnManager = new CdnManager($auth);
12+
13+
$domains = array(
14+
"javasdk.qiniudn.com",
15+
"phpsdk.qiniudn.com"
16+
);
17+
18+
$logDate='2017-08-20';
19+
20+
//获取日志下载链接
21+
//参考文档:http://developer.qiniu.com/article/fusion/api/log.html
22+
23+
list($logListData, $getLogErr) = $cdnManager->getCdnLogList($domains, $logDate);
24+
if ($getLogErr != null) {
25+
var_dump($getLogErr);
26+
} else {
27+
echo "get cdn log list success\n";
28+
print_r($logListData);
29+
}

examples/cdn_manager.php

Lines changed: 0 additions & 89 deletions
This file was deleted.

examples/cdn_refresh_urls_dirs.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../autoload.php';
4+
5+
use \Qiniu\Cdn\CdnManager;
6+
7+
$accessKey = getenv('QINIU_ACCESS_KEY');
8+
$secretKey = getenv('QINIU_SECRET_KEY');
9+
10+
$auth = new Qiniu\Auth($accessKey, $secretKey);
11+
12+
//待刷新的文件列表和目录,文件列表最多一次100个,目录最多一次10个
13+
//参考文档:http://developer.qiniu.com/article/fusion/api/refresh.html
14+
$urls = array(
15+
"http://phpsdk.qiniudn.com/qiniu.jpg",
16+
"http://phpsdk.qiniudn.com/qiniu2.jpg",
17+
);
18+
19+
//刷新目录需要联系七牛技术支持开通账户权限
20+
$dirs = array(
21+
"http://phpsdk.qiniudn.com/test/"
22+
);
23+
24+
$cdnManager = new CdnManager($auth);
25+
26+
// 目前客户默认没有目录刷新权限,刷新会有400038报错,参考:https://developer.qiniu.com/fusion/api/1229/cache-refresh
27+
// 需要刷新目录请工单联系技术支持 https://support.qiniu.com/tickets/category
28+
list($refreshResult, $refreshErr) = $cdnManager->refreshUrlsAndDirs($urls, $dirs);
29+
if ($refreshErr != null) {
30+
var_dump($refreshErr);
31+
} else {
32+
echo "refresh request sent\n";
33+
print_r($refreshResult);
34+
}
35+
36+
//如果只有刷新链接或者目录的需求,可以分布使用
37+
38+
list($refreshResult, $refreshErr) = $cdnManager->refreshUrls($urls);
39+
if ($refreshErr != null) {
40+
var_dump($refreshErr);
41+
} else {
42+
echo "refresh request sent\n";
43+
print_r($refreshResult);
44+
}
45+
46+
list($refreshResult, $refreshErr) = $cdnManager->refreshDirs($dirs);
47+
if ($refreshErr != null) {
48+
var_dump($refreshErr);
49+
} else {
50+
echo "refresh request sent\n";
51+
print_r($refreshResult);
52+
}
53+

examples/fetch.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)