Skip to content

Commit 3d5965f

Browse files
committed
rm ak&sk
1 parent e24abb3 commit 3d5965f

File tree

15 files changed

+344
-12
lines changed

15 files changed

+344
-12
lines changed

examples/bucket_mgr.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use Qiniu\Auth;
55
use Qiniu\Storage\BucketManager;
66

7-
$accessKey = 'XI0n2kV1LYwzcxqSZQxJ7bpycxDIAXFGJMWUt_zG';
8-
$secretKey = '9WTmIAiwKQ2Nq6o93mfKd6VQqq56HjjLZonMWLJl';
7+
$accessKey = 'Access Key';
8+
$secretKey = 'Secret Key';
99

1010
//初始化Auth状态:
1111
$auth = new Auth($accessKey, $secretKey);

examples/bucket_mgr.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
require_once '../autoload.php';
3+
4+
use Qiniu\Auth;
5+
use Qiniu\Storage\BucketManager;
6+
7+
$accessKey = 'Access Key';
8+
$secretKey = '9WTmIAiwKQ2Nq6o93mfKd6VQqq56HjjLZonMWLJl';
9+
10+
//初始化Auth状态:
11+
$auth = new Auth($accessKey, $secretKey);
12+
13+
//初始化BucketManager
14+
$bucketMgr = new BucketManager($auth);
15+
16+
//你要测试的空间, 并且这个key在你空间中存在
17+
$bucket = 'rwxf';
18+
$key = 'php-logo.png';
19+
20+
//获取文件的状态信息
21+
list($ret, $err) = $bucketMgr->stat($bucket, $key);
22+
echo "\n====> $key stat : \n";
23+
if ($err !== null) {
24+
var_dump($err);
25+
} else {
26+
var_dump($ret);
27+
}
28+
29+
//将文件从文件$key 复制到文件$key2。 可以在不同bucket复制
30+
$key2 = 'php-logo2.png';
31+
$err = $bucketMgr->copy($bucket, $key, $bucket, $key2);
32+
echo "\n====> copy $key to $key2 : \n";
33+
if ($err !== null) {
34+
var_dump($err);
35+
} else {
36+
echo "Success!";
37+
}
38+
39+
//将文件从文件$key2 移动到文件$key3。 可以在不同bucket移动
40+
$key3 = 'php-logo3.png';
41+
$err = $bucketMgr->move($bucket, $key2, $bucket, $key3);
42+
echo "\n====> move $key2 to $key3 : \n";
43+
if ($err !== null) {
44+
var_dump($err);
45+
} else {
46+
echo "Success!";
47+
}
48+
49+
//删除$bucket 中的文件 $key
50+
$err = $bucketMgr->delete($bucket, $key3);
51+
echo "\n====> delete $key3 : \n";
52+
if ($err !== null) {
53+
var_dump($err);
54+
} else {
55+
echo "Success!";
56+
}

examples/callback.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
require_once '../autoload.php';
3+
4+
use Qiniu\Auth;
5+
6+
$accessKey = 'QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm';
7+
$secretKey = 'Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz';
8+
$auth = new Auth($accessKey, $secretKey);
9+
10+
//获取回调的body信息
11+
$callbackBody = file_get_contents('php://input');
12+
13+
//回调的contentType
14+
$contentType = 'application/x-www-form-urlencoded';
15+
16+
//回调的签名信息,可以验证该回调是否来自七牛
17+
$authorization = $_SERVER['HTTP_AUTHORIZATION'];
18+
19+
//七牛回调的url,具体可以参考:http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html
20+
$url = 'http://172.30.251.210/callback.php';
21+
22+
$isQiniuCallback = $auth->verifyCallback($contentType, $authorization, $url, $callbackBody);
23+
24+
if ($isQiniuCallback) {
25+
$resp = array('ret' => 'success');
26+
} else {
27+
$resp = array('ret' => 'failed');
28+
}
29+
30+
echo json_encode($resp);

examples/download_token.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use Qiniu\Auth;
55

6-
$accessKey = 'XI0n2kV1LYwzcxqSZQxJ7bpycxDIAXFGJMWUt_zG';
7-
$secretKey = '9WTmIAiwKQ2Nq6o93mfKd6VQqq56HjjLZonMWLJl';
6+
$accessKey = 'Access Key';
7+
$secretKey = 'Secret Key';
88

99
// 构建Auth对象
1010
$auth = new Auth($accessKey, $secretKey);

examples/download_token.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
require_once '../autoload.php';
3+
4+
use Qiniu\Auth;
5+
6+
$accessKey = 'Access Key';
7+
$secretKey = '9WTmIAiwKQ2Nq6o93mfKd6VQqq56HjjLZonMWLJl';
8+
9+
// 构建Auth对象
10+
$auth = new Auth($accessKey, $secretKey);
11+
12+
// 私有空间中的外链 http://<domain>/<file_key>
13+
$baseUrl = 'http://sslayer.qiniudn.com/1.jpg?imageView2/1/h/500';
14+
// 对链接进行签名
15+
$signedUrl = $auth->privateDownloadUrl($baseUrl);
16+
17+
echo $signedUrl;

examples/fetch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use Qiniu\Auth;
55
use Qiniu\Storage\BucketManager;
66

7-
$accessKey = 'XI0n2kV1LYwzcxqSZQxJ7bpycxDIAXFGJMWUt_zG';
8-
$secretKey = '9WTmIAiwKQ2Nq6o93mfKd6VQqq56HjjLZonMWLJl';
7+
$accessKey = 'Access Key';
8+
$secretKey = 'Secret Key';
99

1010
$auth = new Auth($accessKey, $secretKey);
1111
$bmgr = new BucketManager($auth);

examples/fetch.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
require_once '../autoload.php';
3+
4+
use Qiniu\Auth;
5+
use Qiniu\Storage\BucketManager;
6+
7+
$accessKey = 'Access Key';
8+
$secretKey = '9WTmIAiwKQ2Nq6o93mfKd6VQqq56HjjLZonMWLJl';
9+
10+
$auth = new Auth($accessKey, $secretKey);
11+
$bmgr = new BucketManager($auth);
12+
13+
$url = 'http://php.net/favicon.ico';
14+
$bucket = 'rwxf';
15+
$key = time() . '.ico';
16+
17+
list($ret, $err) = $bmgr->fetch($url, $bucket, $key);
18+
echo "=====> fetch $url to bucket: $bucket key: $key\n";
19+
if ($err !== null) {
20+
var_dump($err);
21+
} else {
22+
echo 'Success';
23+
}

examples/list_file.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use Qiniu\Auth;
55
use Qiniu\Storage\BucketManager;
66

7-
$accessKey = 'XI0n2kV1LYwzcxqSZQxJ7bpycxDIAXFGJMWUt_zG';
8-
$secretKey = '9WTmIAiwKQ2Nq6o93mfKd6VQqq56HjjLZonMWLJl';
7+
$accessKey = 'Access Key';
8+
$secretKey = 'Secret Key';
99
$auth = new Auth($accessKey, $secretKey);
1010
$bucketMgr = new BucketManager($auth);
1111

examples/list_file.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
require_once '../autoload.php';
3+
4+
use Qiniu\Auth;
5+
use Qiniu\Storage\BucketManager;
6+
7+
$accessKey = 'Access Key';
8+
$secretKey = '9WTmIAiwKQ2Nq6o93mfKd6VQqq56HjjLZonMWLJl';
9+
$auth = new Auth($accessKey, $secretKey);
10+
$bucketMgr = new BucketManager($auth);
11+
12+
$bucket = 'rwxf';
13+
$prefix = '';
14+
$marker = '';
15+
$limit = 3;
16+
17+
list($iterms, $marker, $err) = $bucketMgr->listFiles($bucket, $prefix, $marker, $limit);
18+
if ($err !== null) {
19+
echo "\n====> list file err: \n";
20+
var_dump($err);
21+
} else {
22+
echo "Marker: $marker\n";
23+
echo "\nList Iterms====>\n";
24+
var_dump($iterms);
25+
}

examples/mkzip.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
$accessKey = 'access key';
99
$secretKey = 'secret key';
1010

11-
$accessKey = 'XI0n2kV1LYwzcxqSZQxJ7bpycxDIAXFGJMWUt_zG';
12-
$secretKey = '9WTmIAiwKQ2Nq6o93mfKd6VQqq56HjjLZonMWLJl';
11+
$accessKey = 'Access Key';
12+
$secretKey = 'Secret Key';
1313
$auth = new Auth($accessKey, $secretKey);
1414

1515

0 commit comments

Comments
 (0)