Home  >  Article  >  Backend Development  >  七牛 删除文件报错 string(11) "No URL set!"

七牛 删除文件报错 string(11) "No URL set!"

WBOY
WBOYOriginal
2016-06-06 20:36:561080browse

require_once("qiniu/rs.php");

Qiniu_SetKeys(YOUR_APP_ACCESS_KEY, YOUR_APP_SECRET_KEY);

$client = new Qiniu_MacHttpClient(null);

$err = Qiniu_RS_Delete($client, 空间名, 文件名);
if ($err !== null) {
var_dump($err);
exit();
}

array(2) { [0]=> NULL [1]=> object(Qiniu_Error)#5 (4) { ["Err"]=> string(11) "No URL set!" ["Reqid"]=> NULL ["Details"]=> NULL ["Code"]=> int(0) } }

我哪里写错了吗?

回复内容:

require_once("qiniu/rs.php");

Qiniu_SetKeys(YOUR_APP_ACCESS_KEY, YOUR_APP_SECRET_KEY);

$client = new Qiniu_MacHttpClient(null);

$err = Qiniu_RS_Delete($client, 空间名, 文件名);
if ($err !== null) {
var_dump($err);
exit();
}

array(2) { [0]=> NULL [1]=> object(Qiniu_Error)#5 (4) { ["Err"]=> string(11) "No URL set!" ["Reqid"]=> NULL ["Details"]=> NULL ["Code"]=> int(0) } }

我哪里写错了吗?

可以调试一下,看看这个是url没有设置

是curl 库报的错误, curl库的 CURLOPT_URL 没有设置

你到qiniu/http.php中找到Qiniu_MacHttpClient这个class,简单修改下RoundTrip函数在return前打印下请求:

<code>public function RoundTrip($req) // => ($resp, $error)
{
    $incbody = Qiniu_Client_incBody($req);
    $token = $this->Mac->SignRequest($req, $incbody);
    $req->Header['Authorization'] = "QBox $token";
    var_dump($req);
    return Qiniu_Client_do($req);
}
</code>

看下请求中的url是否正确。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn