I don't get prices with Amazon Product Advertising API
Posted
by
Xarem
on Stack Overflow
See other posts from Stack Overflow
or by Xarem
Published on 2011-11-29T01:34:22Z
Indexed on
2011/11/29
1:50 UTC
Read the original article
Hit count: 393
I try to get prices of an ASIN number with the Amazon Product Advertising API.
Code:
$artNr = "B003TKSD8E";
$base_url = "http://ecs.amazonaws.de/onca/xml";
$params = array(
'AWSAccessKeyId' => self::API_KEY,
'AssociateTag' => self::API_ASSOCIATE_TAG,
'Version' => "2010-11-01",
'Operation' => "ItemLookup",
'Service' => "AWSECommerceService",
'Condition' => "All",
'IdType' => 'ASIN',
'ItemId' => $artNr);
$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.de\n/onca/xml\n" . $url_string;
$signature = hash_hmac("sha256", $string_to_sign, self::API_SECRET, TRUE);
$signature = urlencode(base64_encode($signature));
$url = $base_url . '?' . $url_string . "&Signature=" . $signature;
$response = file_get_contents($url);
$parsed_xml = simplexml_load_string($response);
I think this should be correct - but I don't get offers in the response:
SimpleXMLElement Object
(
[OperationRequest] => SimpleXMLElement Object
(
[RequestId] => *************************
[Arguments] => SimpleXMLElement Object
(
[Argument] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Condition
[Value] => All
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Operation
[Value] => ItemLookup
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Service
[Value] => AWSECommerceService
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => ItemId
[Value] => B003TKSD8E
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => IdType
[Value] => ASIN
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => AWSAccessKeyId
[Value] => *************************
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Timestamp
[Value] => 2011-11-29T01:32:12.000Z
)
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Signature
[Value] => *************************
)
)
[8] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => AssociateTag
[Value] => *************************
)
)
[9] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Version
[Value] => 2010-11-01
)
)
)
)
[RequestProcessingTime] => 0.0091540000000000
)
[Items] => SimpleXMLElement Object
(
[Request] => SimpleXMLElement Object
(
[IsValid] => True
[ItemLookupRequest] => SimpleXMLElement Object
(
[Condition] => All
[IdType] => ASIN
[ItemId] => B003TKSD8E
[ResponseGroup] => Small
[VariationPage] => All
)
)
[Item] => SimpleXMLElement Object
(
[ASIN] => B003TKSD8E
[DetailPageURL] => http://www.amazon.de/Apple-iPhone-4-32GB-schwarz/dp/B003TKSD8E%3FSubscriptionId%3DAKIAI6NFQHK2DQIPRUEQ%26tag%3Dbanholzerme-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB003TKSD8E
[ItemLinks] => SimpleXMLElement Object
(
[ItemLink] => Array
(
[0] => SimpleXMLElement Object
(
[Description] => Add To Wishlist
[URL] => http://www.amazon.de/gp/registry/wishlist/add-item.html%3Fasin.0%3DB003TKSD8E%26SubscriptionId%3DAKIAI6NFQHK2DQIPRUEQ%26tag%3Dbanholzerme-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB003TKSD8E
)
[1] => SimpleXMLElement Object
(
[Description] => Tell A Friend
[URL] => http://www.amazon.de/gp/pdp/taf/B003TKSD8E%3FSubscriptionId%3DAKIAI6NFQHK2DQIPRUEQ%26tag%3Dbanholzerme-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB003TKSD8E
)
[2] => SimpleXMLElement Object
(
[Description] => All Customer Reviews
[URL] => http://www.amazon.de/review/product/B003TKSD8E%3FSubscriptionId%3DAKIAI6NFQHK2DQIPRUEQ%26tag%3Dbanholzerme-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB003TKSD8E
)
[3] => SimpleXMLElement Object
(
[Description] => All Offers
[URL] => http://www.amazon.de/gp/offer-listing/B003TKSD8E%3FSubscriptionId%3DAKIAI6NFQHK2DQIPRUEQ%26tag%3Dbanholzerme-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB003TKSD8E
)
)
)
[ItemAttributes] => SimpleXMLElement Object
(
[Manufacturer] => Apple Computer
[ProductGroup] => CE
[Title] => Apple iPhone 4 32GB schwarz
)
)
)
)
Can someone please explain me why I don't get any price-information?
Thank you very much
© Stack Overflow or respective owner