Skip to content

Commit 72b7383

Browse files
committed
feat: add cdn demo
1 parent 03672fa commit 72b7383

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

examples/cdn_get_prefetch_list.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../autoload.php';
4+
5+
use Qiniu\Auth;
6+
use Qiniu\Cdn\CdnManager;
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+
// 查询 CDN 预取记录
16+
// 参考文档:https://developer.qiniu.com/fusion/api/1227/file-prefetching#4
17+
18+
$requestId = null; // 指定要查询记录所在的刷新请求id
19+
$urls = null; // 要查询的url列表
20+
$state = 'success'; // 指定要查询记录的状态,取值 processing/success/failure
21+
$pageNo = 0; // 要求返回的页号,默认为0
22+
$pageSize = 100; // 要求返回的页长度,默认为100
23+
$startTime = '2020-09-11 12:00:00'; // 指定查询的开始日期,格式2006-01-01
24+
$endTime = '2020-09-20 21:00:00'; // 指定查询的结束日期,格式2006-01-01
25+
26+
list($ret, $err) = $cdnManager->getCdnPrefetchList(
27+
$requestId,
28+
$urls,
29+
$state,
30+
$pageNo,
31+
$pageSize,
32+
$startTime,
33+
$endTime
34+
);
35+
echo "\n====> query prefetch list: \n";
36+
if ($err !== null) {
37+
var_dump($err);
38+
} else {
39+
var_dump($ret);
40+
}

examples/cdn_get_refresh_list.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../autoload.php';
4+
5+
use Qiniu\Auth;
6+
use Qiniu\Cdn\CdnManager;
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+
// 查询 CDN 刷新记录
16+
// 参考文档:https://developer.qiniu.com/fusion/api/1229/cache-refresh#4
17+
18+
$requestId = 'xxxxxx'; // 指定要查询记录所在的刷新请求id
19+
$isDir = 'no'; // 指定是否查询目录,取值为yes/no,默认不填则为两种类型记录都查询
20+
$urls = array(); // 要查询的url列表,每个url可以是文件url,也可以是目录url
21+
$state = 'success'; // 指定要查询记录的状态,取值 processing/success/failure
22+
$pageNo = 0; // 要求返回的页号,默认为0
23+
$pageSize = 100; // 要求返回的页长度,默认为100
24+
$startTime = '2020-09-11 12:00:00'; // 指定查询的开始日期,格式2006-01-01
25+
$endTime = '2020-09-20 21:00:00'; // 指定查询的结束日期,格式2006-01-01
26+
27+
list($ret, $err) = $cdnManager->getCdnRefreshList(
28+
$requestId,
29+
$isDir,
30+
$urls,
31+
$state,
32+
$pageNo,
33+
$pageSize,
34+
$startTime,
35+
$endTime
36+
);
37+
echo "\n====> query refresh list: \n";
38+
if ($err !== null) {
39+
var_dump($err);
40+
} else {
41+
var_dump($ret);
42+
}

0 commit comments

Comments
 (0)