我已經查看了基於此堆棧溢出問題的大多數代碼示例,但仍無法獲得工作請求。我不斷收到此錯誤:我們計算的請求籤名不匹配AMAZON AWS PHP
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
這裏是我的代碼:
$access_key = "ACCESS_KEY";
$associateTag = "AOSSOCIATE_TAG";
$secretkey = "SECRET_KEY";
$keywords = "harry%20potter";
$timestamp = gmdate("Y-m-d\TH:i:s\Z");
$operation = "AWSECommerceService";
function createSignature($operation,$timestamp,$secretkey){
$the_string=$operation.$timestamp;
return base64_encode(hash_hmac("sha256",$the_string,$secretkey,true));
}
$signature = createSignature ($operation,$timestamp,$secretkey);
$APIcall =
"http://ecs.amazonaws.com/onca/xml?".
"AWSAccessKeyId=$access_key&".
"AssociateTag=$associateTag&".
"BrowseNode=1000&".
"ItemPage=1&".
"Keywords=$keywords&".
"Operation=ItemSearch&".
"ResponseGroup=Medium&".
"SearchIndex=Books&".
"Service=AWSECommerceService&".
"Timestamp=$timestamp&".
"Version=2011-08-01&".
"Signature=$signature";
$response = simplexml_load_file($APIcall);
誰能幫助?
爲什麼地球上有這樣的麻煩,當有一個完美的良好支持的PHP API可以直接從亞馬遜使用? http://aws.amazon.com/sdkforphp/ – ceejayoz 2013-02-11 17:50:53
因爲我覺得安裝SDK有點超出了我想達到的目的,所以我最終只是想根據關鍵字在側邊欄中顯示來自亞馬遜的3個項目就是這樣,只是覺得自己做這件事會更笨重和更快。 – AJFMEDIA 2013-02-11 18:40:21
安裝SDK需要幾分鐘時間。你已經明確地花費了至少那試圖自己做,解決問題,並張貼在這裏。 – ceejayoz 2013-02-11 18:42:39