我尝试创建签名以删除下面的照片。
$args = array(
'method' => 'flickr.photos.delete',
'format' => 'php_serial',
'api_key' => $this->api_key,
'photo_id' => $photoId,
'auth_token' => $this->token,
);
ksort($args);
$auth_sig = "";
foreach ($args as $key => $data) {
if ( is_null($data) ) {
unset($args[$key]);
continue;
}
$auth_sig .= $key . $data;
$api_sig = md5($this->secret . $auth_sig);
}
但是当我为api flickr.photos.delete使用签名时,虽然我仍然上传并替换了图片成功,但我收到了消息无效签名。
这是代码调用api flickr.photos.delete,
$params = array(
'method' => 'flickr.photos.delete',
'format' => 'php_serial',
'api_key' => $this->api_key,
'photo_id' => $photoId,
'auth_token' => $this->token,
'perms' => 'write',
'api_sig' =>$api_sig
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k).'='.urlencode($v);
}
$url = $this->rest_endpoint."?".implode('&', $encoded_params);
$rsp = file_get_contents($url);
$rsp_obj = unserialize($rsp);
var_dump($rsp_obj);
如何解决此问题?