0

我有亚马逊 API,它工作正常。但是输出总是来自美国商店(amazon.com),但我想从英国商店(amazon.co.uk)得到它我应该怎么做?

$AWSAccessKeyId = "KEYID";
$SecretAccessKey = "ACCESKEY";

$ItemId = "12345"; // ASIN and ISBN10 or ISBN13

if(strlen($ItemId)>=13){
    $ItemId = isbn13to10($ItemId);
}

$Timestamp = gmdate("Y-m-d\TH:i:s\Z");
$Timestamp = str_replace(":", "%3A", $Timestamp);
$ResponseGroup = "ItemAttributes,Offers,Images,Reviews";
$ResponseGroup = str_replace(",", "%2C", $ResponseGroup);

$String  = "AWSAccessKeyId=$AWSAccessKeyId&AssociateTag=notUsed&";
$String .= "ItemId=$ItemId&
Operation=ItemLookup&
ResponseGroup=Offers&
Service=AWSECommerceService&";

$String .= "Timestamp=$Timestamp&
Version=2009-01-06";

$String = str_replace("\n", "", $String);

$Prepend = "GET\nwebservices.amazon.com\n/onca/xml\n";
$PrependString = $Prepend . $String;

$Signature = base64_encode(hash_hmac("sha256", $PrependString, $SecretAccessKey, True));  
$Signature = str_replace("+", "%2B", $Signature);
$Signature = str_replace("=", "%3D", $Signature);

$BaseUrl = "http://webservices.amazon.com/onca/xml?";
$SignedRequest = $BaseUrl . $String . "&Signature=" . $Signature;

$XML = simplexml_load_file($SignedRequest);
4

1 回答 1

0

啊,这很容易……容易到让人没想到……

$Prepend = "GET\nwebservices.amazon.co.uk\n/onca/xml\n";
$BaseUrl = "http://webservices.amazon.co.uk/onca/xml?";
于 2013-10-26T19:22:24.510 回答