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);}
回复内容: 返回的结果是401 sign error
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);}
$path 后面加 \n,类似:http://www.xx.com/a/b.jpg\n
