我使用以下代码获取有关亚马逊产品的信息:
$id = "B00355GLBY";
$base_url = "http://ecs.amazonaws.com/onca/xml";
$params = array(
'AWSAccessKeyId' => "AWSAccessKey",
'AssociateTag' => "AssociateTag",
'Version' => "2011-08-01",
'Operation' => "ItemLookup",
'Service' => "AWSECommerceService",
'Condition' => "All",
'IdType' => 'ASIN',
'ResponseGroup' => 'Offers, Images, ItemAttributes',
'MerchantId' => 'All',
'ItemId' => $id);
$params['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
$url_parts = array();
foreach(array_keys($params) as $key)
$url_parts[] = $key . "=" . str_replace('%7E', '~', rawurlencode($params[$key]));
sort($url_parts);
$url_string = implode("&", $url_parts);
$string_to_sign = "GET\necs.amazonaws.com\n/onca/xml\n" . $url_string;
$signature = hash_hmac("sha256", $string_to_sign, "SECRET_KEY", TRUE);
$signature = urlencode(base64_encode($signature));
$url = $base_url . '?' . $url_string . "&Signature=" . $signature;
$parsed_xml = simplexml_load_file($url);
$original_price = $parsed_xml->Items->Item->Offers->Offer->OfferListing->Price->FormattedPrice;
$original_image = $parsed_xml->Items->Item->LargeImage->URL;
$stock = $parsed_xml->Items->Item->Offers->Offer->OfferListing->AvailabilityAttributes->AvailabilityType;
$original_product_name = $parsed_xml->Items->Item->ItemAttributes->Title;
我的问题是有时候我得到错误的价格回报。 比如使用这个ASIN:B005Y6F4WO,我得到的价格是:0.87 $ 我想收到页面中心显示的(主要)价格。我怎样才能使它工作? 感谢。
答案 0 :(得分:0)
对于仍有问题的人......如果检索到的价格低于亚马逊本身,那么这些价格似乎是由API返回所有卖家的最低价格造成的。您可以尝试检查Condition = New而不是All。
我使用WooZone Amazon Affiliate for Wordpress,它有这些问题。