Skip to content

Commit 56c3e4b

Browse files
committed
add fetch demo
1 parent ae52f18 commit 56c3e4b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

demos/fetch.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
require_once '../vendor/autoload.php';
3+
4+
use Qiniu\Auth;
5+
use Qiniu\Storage\BucketManager;
6+
7+
$accessKey = 'XI0n2kV1LYwzcxqSZQxJ7bpycxDIAXFGJMWUt_zG';
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+
{
21+
var_dump($err);
22+
} else {
23+
var_dump($ret);
24+
}
25+

0 commit comments

Comments
 (0)