This repository has been archived by the owner on Mar 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Working with the results in PHP
samedney edited this page Nov 26, 2010
·
11 revisions
Here is a very simple foreach loop that pulls the results as an array, and loops through the items, displaying the title.
define('AWS_API_KEY', 'AKIAISMXSLAEW6HD3JEQ');
define('AWS_API_SECRET_KEY', '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');
require 'lib/AmazonECS.class.php';
$amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'UK');
$amazonEcs->setReturnType(AmazonECS::RETURN_TYPE_ARRAY);
$response = $amazonEcs->category('All')->search('Xbox');
if (isset($response['Items']['Item']) ) {
foreach ($response['Items']['Item'] as $result) {
echo "<p style='min-height: 60px;'>";
echo "<a target='isitAmazonWindow' href='" . $result['DetailPageURL'] ."'>";
if (isset($result['SmallImage']['URL'] )) {
echo "<img style=' margin: 0px; margin-left: 10px; border: 1px solid black; max-height: 55px;' align='right' src='". $result['SmallImage']['URL'] ."'>";
}
echo $result['ItemAttributes']['Title'] . "<br/>";
echo "<small>";
if (isset($result['ItemAttributes']['Brand'])) {
echo $result['ItemAttributes']['Brand'] ;
}
echo "</small>";
echo "</a>";
echo "</p>";
}
} else {
echo "<p>No suggestions found</p>";
}
I haven’t checked to see if this actually works yet, as I will need to buy something to see the process through. It looks as though the URL is correct for making a purchase, and linking it to the Amazon associate (affiliate) ID.
$affiliateId = "XXXX123456-21";
$asin = $result['ASIN'];
echo "<a target='_Blank' href='http://www.amazon.co.uk/gp/product/".$asin."?ie=UTF8&tag=".$affiliateId."&linkCode=as2&camp=1634&creative=6738&creativeASIN=".$asin."'>";
if (isset($result['SmallImage']['URL'] )) {
echo "<img style=' margin: 0px; margin-left: 10px; border: 1px solid black; max-height: 55px;' align='right' src='". $result['SmallImage']['URL'] ."'>";
}
if (isset($result['ItemAttributes']['Title'])) {
echo $result['ItemAttributes']['Title'] . "<br/>";
}
echo "<small>";
if (isset($result['ItemAttributes']['Brand'])) {
echo $result['ItemAttributes']['Brand'] ;
}
echo "</small>";
echo "</a>";