+ Check another Amazon.com item'."\n";
//set Amazon Web Services Developer ID - MUST be changed for personal use, accounts available from https://aws-portal.amazon.com/gp/aws/developer/registration/index.html
$aws_developer_key = '1DBY9V8DKZ6RAK1M7NG2';
//build request URL for specific developer and item id
$request = 'http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId='.$aws_developer_key.'&Operation=ItemLookup&ItemId='.$id.'&ResponseGroup=Images,ItemAttributes,EditorialReview,Reviews&Version=2007-07-16';
//make request to Amazon E-Commerce Web Service using "xml load file" function from PHP
$xml = simplexml_load_file($request) or die("xml response not loading");
//set Amazon xml values as specifc variables to be printed out below
$image = $xml->Items->Item->MediumImage->URL;
if (empty($image)) { $image = '* Image Not Available'; }
$title = $xml->Items->Item->ItemAttributes->Title;
$author = $xml->Items->Item->ItemAttributes->Author;
//simple logic check for author and director values, shows
if (strlen($author) > 2) {
$creator = $author;
} elseif (empty($author)) {
$creator = $xml->Items->Item->ItemAttributes->Director;
} else {
$creator = '* Creator Not Available';
}
$asin = $xml->Items->Item->ASIN;
$uri = $xml->Items->Item->DetailPageURL;
$editorialReview = $xml->Items->Item->EditorialReviews->EditorialReview->Content;
//print out Amazon xml values as html
echo '
'."\n";
echo ''.$title.'
'."\n";
echo ''.$creator.'
ID (isbn or asin): '.$asin.'
+ Get full details
'."\n";
echo 'Editorial review: '.html_entity_decode($editorialReview).'
'."\n";
echo 'What others are saying...
'."\n";
echo ''."\n";
foreach ($xml->Items->Item->CustomerReviews->Review as $review) {
echo '- '.html_entity_decode($review->Summary).'
'."\n";
echo '- '.html_entity_decode($review->Content).'
'."\n";
echo '- Rating: '.html_entity_decode($review->Rating).' out of 5
'."\n";
echo '
'."\n";
}
echo '
'."\n";
?>