1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
|
<?php
$method = "GET";
$host = "ecs.amazonaws.de";
$uri = "/onca/xml";
$public_key = "xxxxx";
$private_key = "xxxx";
$params["Service"] = "AWSECommerceService";
$params["AWSAccessKeyId"] = $public_key;
// GMT timestamp
$params["Timestamp"] = gmdate("Y-m-d\TH:i:s\Z");
// API version
$params["Version"] = "2009-03-31";
$params["Operation"] = "ItemLookup";
$params["ResponseGroup"] = "Large";
$params["ItemId"] = array("3453545249","3453545346","3866081391","3866081480","3940505366","394050534X");
ksort($params);
foreach ($params["ItemId"] as $params["ItemId"])
{
$canonicalized_query = array();
foreach ($params as $param=>$value) {
$param = str_replace("%7E", "~", rawurlencode($param));
$value = str_replace("%7E", "~", rawurlencode($value));
$canonicalized_query[] = $param."=".$value;
}
$canonicalized_query = implode("&", $canonicalized_query);
$string_to_sign = $method."\n".$host."\n".$uri."\n".$canonicalized_query;
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $private_key, true));
$signature = str_replace("%7E", "~", rawurlencode($signature));
$request = "http://".$host.$uri."?".$canonicalized_query."&Signature=".$signature;
//XML-Datei abrufen
$xmlItemResult = simplexml_load_file($request);
$myImage = $xmlItemResult->Items->Item->MediumImage->URL;
echo "<img src='".$myImage."' title=\"\" /><br />";
echo "Titel: ".utf8_decode($xmlItemResult->Items->Item->ItemAttributes->Title)."<br>";
echo "Autor: ".utf8_decode($xmlItemResult->Items->Item->ItemAttributes->Author)."<br>";
echo "Format: ".utf8_decode($xmlItemResult->Items->Item->ItemAttributes->Binding)."<br>";
echo "Auflage: ".utf8_decode($xmlItemResult->Items->Item->ItemAttributes->Edition)."<br>";
echo "ISBN: ".utf8_decode($xmlItemResult->Items->Item->ItemAttributes->ISBN)."<br>";
echo "Verlag: ".utf8_decode($xmlItemResult->Items->Item->ItemAttributes->Label)."<br>";
echo "Preis: ".utf8_decode($xmlItemResult->Items->Item->ItemAttributes->ListPrice->FormattedPrice)."<br>";
echo "Seiten: ".utf8_decode($xmlItemResult->Items->Item->ItemAttributes->NumberOfPages)."<br /><br />";
echo "Zum Inhalt: ".@utf8_decode($xmlItemResult->Items->Item->EditorialReviews->EditorialReview->Content)."<br /><br />";
}
?>
|