• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

upyun 刷新缓存的签名不知道哪错了

php 搞代码 3年前 (2022-01-25) 18次浏览 已收录 0个评论
文章目录[隐藏]

返回的结果是401 Sign error

<code>public function delete($path) {    //比如http://www.xx.com/a/b.jpg,我传过来删除的就是/a/b.jpg    //删除部分略过    //刷新缓存开始    $ch = curl_init('http://purge.upyun.com/purge/');    $date = gmdate('D, d M Y H:i:s \G\M\T');    //这里签名我是直接用的$path,我是怀疑这里错了 但是我试过http://www.xx.com加在前面也还是错误    $sign = md5($path.'&'.$this->bucket.'&'.$date.'&'.md5($this->password));    //头信息    $header = array(        'Expect: ""',        'Authorization: UpYun '.$this->config['bucket'].':'.$this->config['username'].':'.$sign,        'Date: '.$date,        'Content-Type: application/x-www-form-urlencoded',    );    curl_setopt($ch,CURLOPT_HTTPHEADER,$header);    //POST方式    curl_setopt($ch,CURLOPT_POST,1);    //这里也是个问题,我不知道这个要不要提交过去    $data = array(        'purge' => urlencode($path),    );    curl_setopt($ch,CURLOPT_POSTFIELDS,$data);    //是否返回头信息    curl_setopt($ch,CURLOPT_HEADER,1);    $response = curl_exec($ch);    $status = curl_getinfo($ch,CURLINFO_HTTP_CODE);    curl_close($ch);    //打印结果    var_dump($response);}</code>

回复内容:

返回的结果是401 Sign error

<code>public function delete($path) {    //比如http://www.xx.com/a/b.jpg,我传过来删除的就是/a/b.jpg    //删除部分略过    //刷新缓存开始    $ch = curl_init('http://purge.upyun.com/purge/');    $date = gmdate('D, d M Y H:i:s \G\M\T');    //这里签名我是直接用的$path,我是怀疑这里错了 但是我试过http://www.xx.com加在前面也还是错误    $sign = md5($path.'&'.$this->bucket.'&'.$date.'&'.md5($this->password));    //头信息    $header = array(        'Expect: ""',        'Authorization: UpYun '.$this->config['bucket'].':'.$this->config['username'].':'.$sign,        'Date: '.$date,        'Content-Type: application/x-www-form-urlencoded',    );    curl_setopt($ch,CURLOPT_HTTPHEADER,$header);    //POST方式    curl_setopt($ch,CURLOPT_POST,1);    //这里也是个问题,我不知道这个要不要提交过去    $data = array(        'purge' => urlencode($path),    );    curl_setopt($ch,CURLOPT_POSTFIELDS,$data);    //是否返回头信息<strong>)本文来(源gaodai#ma#com搞@@代~&码*网2</strong><pre>搞代gaodaima码

curl_setopt($ch,CURLOPT_HEADER,1); $response = curl_exec($ch); $status = curl_getinfo($ch,CURLINFO_HTTP_CODE); curl_close($ch); //打印结果 var_dump($response);}

$path 后面加 \n,类似:http://www.xx.com/a/b.jpg\n


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:upyun 刷新缓存的签名不知道哪错了
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址