代码如下:
$v = "https://xxx.qbox.me/xxxxx.mp3";
$encodedURL = str_replace(['+', '/'], ['-', '_'], base64_encode($v));
$encodedEntryURI = str_replace(['+', '/'], ['-', '_'],base64_encode($qiniu_config['bucket']));
$url = '/fetch/' . $encodedURL . '/to/' . $encodedEntryURI;
$sign = hash_hmac('sha1', $url . "\n", $qiniu_config['secretKey'], true);
$token = $qiniu_config['accessKey'] . ':' . str_replace(['+', '/'], ['-', '_'], base64_encode($sign));
$header = ['Host: iovip.qbox.me', 'Content-Type:application/x-www-form-urlencoded', 'Authorization: QBox ' . $token];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, trim('http://iovip.qbox.me' . $url, '\n'));
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, "");
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
if (isset($result['error'])) {
throw new Exception('文件上传失败: ' . $result['error'])
}
抛出错误:
bad token
打印出来$token是有值的。。。。
请问是怎么回事啊??
谢邀,看下官方文档https://qiniu.kf5.com/hc/kb/a...,然后按1234点检查下