已参照此贴: http://segmentfault.com/q/1010000000331820 中的PHP代码进行获取token,
php代码:
require_once('php-sdk/qiniu/rs.php');
require_once('php-sdk/qiniu/http.php');
require_once('php-sdk/qiniu/auth_digest.php');
require_once('php-sdk/qiniu/utils.php');
$bucket = "[***bucket-name***]";
$key = "big.mpg";
$accessKey = '********************************';
$secretKey = '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@';
Qiniu_SetKeys($accessKey, $secretKey);
$mac = new Qiniu_Mac($accessKey, $secretKey);
$fop = 'fop1';
$query = "bucket=$bucket&key=$key&fops={$fop}¬ifyURL=http://www.example.com";
$sign_data = "/pfop/\n" . $query;
$accessToken = $mac->Sign($sign_data);
$client = new Qiniu_MacHttpClient($mac);
echo $accessToken . "\n";
然后使用
curl -d "bucket=[***bucket-name***]&key=big.mpg&fops=fop1¬ifyURL=http://www.example.com" --header "Content-Type: application/x-www-form-urlencoded" --header "Authorization: QBox ******************************:1LaTz-y0LS0qP390ba6_ZLlsW20=" "http://api.qiniu.com/pfop/"
始终返回 bad token
实在找不出哪里出了问题了
参考这个 demo 代码:https://github.com/qiniu/php-sdk/blob/develop/docs/gist/pfop.php