Skip to content

Commit

Permalink
Merge pull request #67 from dtynn/feature/gist
Browse files Browse the repository at this point in the history
新增接口的调用范例
  • Loading branch information
longbai committed Apr 5, 2014
2 parents fefa494 + c3bc426 commit 5768edc
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## CHANGE LOG

### v6.1.9

2014-04-03 issues [#67](https://github.com/qiniu/php-sdk/pull/67)

- 新增3个新接口:fetch、prefetch、pfop的调用范例代码,需要使用这三个接口的用户可以参考。

### v6.1.8

2014-3-31 issues [#66](https://github.com/qiniu/php-sdk/pull/66)
Expand Down
32 changes: 32 additions & 0 deletions docs/gist/fetch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

require_once("../../qiniu/http.php");
require_once("../../qiniu/auth_digest.php");
require_once("../../qiniu/utils.php");

$accessKey = "";
$secretKey = "";
$targetUrl = "";

$destBucket = "";
$destKey = "";

$encodedUrl = Qiniu_Encode($targetUrl);

$destEntry = "$destBucket:$destKey";
$encodedEntry = Qiniu_Encode($destEntry);

$apiHost = "http://iovip.qbox.me";
$apiPath = "/fetch/$encodedUrl/to/$encodedEntry";
$requestBody = "";

$mac = new Qiniu_Mac($accessKey, $secretKey);
$client = new Qiniu_MacHttpClient($mac);

list($ret, $err) = Qiniu_Client_CallWithForm($client, $apiHost . $apiPath, $requestBody);
if ($err !== null) {
echo "failed\n";
var_dump($err);
} else {
echo "success\n";
}
39 changes: 39 additions & 0 deletions docs/gist/pfop.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

require_once("../../qiniu/http.php");
require_once("../../qiniu/auth_digest.php");
require_once("../../qiniu/utils.php");

$accessKey = "";
$secretKey = "";

$bucket = "";
$key = "";
$fops = "";
$notifyURL = "";
$force = 0;


$encodedBucket = urlencode($bucket);
$encodedKey = urlencode($key);
$encodedFops = urlencode($fops);
$encodedNotifyURL = urlencode($notifyURL);

$apiHost = "http://api.qiniu.com";
$apiPath = "/pfop/";
$requestBody = "bucket=$encodedBucket&key=$encodedKey&fops=$encodedFops&notifyURL=$encodedNotifyURL";
if ($force !== 0) {
$requestBody .= "&force=1";
}

$mac = new Qiniu_Mac($accessKey, $secretKey);
$client = new Qiniu_MacHttpClient($mac);

list($ret, $err) = Qiniu_Client_CallWithForm($client, $apiHost . $apiPath, $requestBody);
if ($err !== null) {
echo "failed\n";
var_dump($err);
} else {
echo "success\n";
var_dump($ret);
}
29 changes: 29 additions & 0 deletions docs/gist/prefetch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

require_once("../../qiniu/http.php");
require_once("../../qiniu/auth_digest.php");
require_once("../../qiniu/utils.php");

$accessKey = "";
$secretKey = "";

$bucket = "";
$key = "";

$entry = "$bucket:$key";
$encodedEntry = Qiniu_Encode($entry);

$apiHost = "http://iovip.qbox.me";
$apiPath = "/prefetch/$encodedEntry";
$requestBody = "";

$mac = new Qiniu_Mac($accessKey, $secretKey);
$client = new Qiniu_MacHttpClient($mac);

list($ret, $err) = Qiniu_Client_CallWithForm($client, $apiHost . $apiPath, $requestBody);
if ($err !== null) {
echo "failed\n";
var_dump($err);
} else {
echo "success\n";
}

0 comments on commit 5768edc

Please sign in to comment.