我期待展示亚马逊产品。但我得到signature error
。我已经应用了不同的代码段,但仍然没有进展。.:(
任何帮助将不胜感激。
我们计算出的请求签名与您的签名不匹配 提供。检查您的AWS Secret Access密钥和签名方法。请教 服务文档以了解详细信息。
$AWS_ACCESS_KEY_ID = "MY_ACCESS_KEY";
$AWS_SECRET_ACCESS_KEY = urlencode("MY_SECRET_KEY");
$base_url = "http://webservices.amazon.com/onca/xml?";
$url_params = array('Operation'=>"ItemSearch" , 'Service' => "AWSECommerceService",
'AWSAccessKeyId' => $AWS_ACCESS_KEY_ID , 'AssociateTag' => "mytag-20",
'Version' => "2013-08-01",'Availability'=>"Available",'Condition'=>"All",
'ItemPage'=>"1",'ResponseGroup'=>"Images,ItemAttributes,EditorialReview",
'Keywords'=>"Amazon");
// Add the Timestamp
$url_params['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
// Sort the URL parameters
$url_parts = array();
foreach(array_keys($url_params) as $key){
$url_parts[] = $key."=".$url_params[$key];
}
sort($url_parts);
$string_to_sign = "GET\nwebservices.amazon.com\n/onca/xml\n".implode("&",$url_parts);
$string_to_sign = urlencode($string_to_sign);
$signature = hash_hmac("sha256",$string_to_sign,$AWS_SECRET_ACCESS_KEY,TRUE);
$signature = base64_encode($signature);
$signature = urlencode($signature);
$url_string = implode("&",$url_parts);
$url = $base_url.$url_string."&Signature=".$signature;
print $url;