Amazon API
Hi everyone,
As a very popular addition to Price Tapestry, and with the requirement for Amazon Web Services (AWS) API requests to be authenticated by 15th August 2009, i've updated the script and consolidated the various Amazon related threads into this single page to make it much easier for new users to find the relevant info.
If you are a member of the Amazon Associate Program (.co.uk / .com (US) / .de / .jp) you can complement your Price Tapestry generated product pages and/or search results with live Amazon results via Amazon Web Services. To use the web services, in addition to an associate account you will also need an AWS account.
Download and Installation
Click here to download, and unzip amazon.php to your local computer.
Open the file, and edit the following lines at the top of the script to contain your AWS access key ID, secret access key, and your associate tag where indicated. When logged in to AWS, your access key ID and secret access key can be found on this page.
$amazonAWSAccessKeyId = "YOUR_ACCESS_KEY_ID";
$amazonSecretAccessKey = "YOUR_SECRET_ACCESS_KEY";
$amazonAssociateTag = "YOUR_ASSOCIATE_TAG";To install, simply upload the modified amazon.php to your main Price Tapestry installation folder (probably the top level folder of your site unless you have installed Price Tapestry into a sub-directory).
Usage
Amazon results can be added to both search.php and products.php. In both files, to include Amazon results at the end of the page, look for the the following code towards the end of the script:
require("html/footer.php");...and REPLACE this with:
require("amazon.php");
require("html/footer.php");Customisation for non-UK Locales
If you are not an amazon.co.uk associate you will need to edit line 122 as appropriate, for example by replacing .co.uk with .com (US associates).
Customisation for Niche Sites
One of the parameters in the AWS request generated by the script is "SearchIndex". A value of "Blended" is used by default, which searches all categories. If you are using the script on a niche site, it may be worthwhile using a more appropriate value based on the subject matter of your site. A complete list of SearchIndex values available per locale can be found here. The SearchIndex value can be changed on line 128 of the script.
IMPORTANT: At time of writing, the AWS ECommerce Service is free of charge, but make sure that you are checking the email address associated with your AWS account in case this situation changes in the future.
Hi,
Regarding the number of Amazon results; this is limited to 4 in the script, but you can change this to whatever value you wish by modifying the following code on line 7 of amazon.php:
$amazonItemMax = 4;As Amazon results are API based and not from the local database, it is certainly possible that a query might not return any local results (I presume that search is working correctly for products that are in your database); but for there to be results from Amazon.
What may be worth doing because of this; would be to add some kind of text or more indication that the following results are from parter sites; for example where you have added the code:
require("amazon.php");...you could instead use:
print "<p>Results from Amazon.com...</p>";
require("amazon.php");Hope this helps!
Cheers,
David.
Thanks a bunch, can other data be returned from amazon like product reviews or even just review star rating?
Another quick question I hope anyway. If I wanted to return a larger image in the feed can this be done easily? The medium image would be preferred. Thanks for your help
Hi David,
Is there a way that if no results are found that I can return something like:
<p>Sorry, no results from Amazon were found! </p>
Thanks a lot! -Joe
Hi Joe,
Sure - at the very end of the script simply add the following code:
if (!$amazonItemCount)
{
print "<p>Sorry, no results from Amazon were found!</p>";
}Cheers,
David.
Hi David
Is there a way to add that message to the ebay code?
Thank You
Dean
Hi Dean,
It should be exactly the same, but using:
$ebayItemCount...in place of
$amazonItemCount...for example:
if (!$ebayItemCount)
{
print "<p>Sorry, no results from eBay were found!</p>";
}Cheers,
David.
Hi David,
I went down the route of using OOP with the amazon API along with the neat little encrypton script you kindly wrote for us all.
$response = simplexml_load_file($awsUrl);I am however getting this error message and I can't seem to figure out what is causing it. Could you perhaps point me in the right direction please?
An error occurred in script '/var/www/vhosts/xxxx.co.uk/httpdocs/electricals/modules/amazon/searchAM.php' on line 19: simplexml_load_file(http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&AssociateTag=xxxxx&AWSAccessKeyId=xxxxx&Operation=ItemSearch&ResponseGroup=Medium,EditorialReview&BrowseNode=560798&MerchantId=All&Condition=All&Availability=Available&SearchIndex=Electronics&Keywords=electricalsHEWLETPACK+2015TONER+Q7553A&Sort=salesrank&Version=2009-01-06&Timestamp=2009-09-08T22:38:56Z&Signature=xxxxxxxxxxxxxx) [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily UnavailableThanks,
Simon
Hi Simon,
That's indicating that an HTTP 503 error occurred during the request. The first thing to do is to debug the request by printing out the URL being constructed by your script and then requesting it manually in your web browser.
If it seems to be OK, double-check HTTP requests in general as it might be something caused by the local network, for example:
<?php
$response = file_get_contents("http://www.example.com/");
?>
If that generates the same error; it might be worth giving CURL a try as an alternative. The following block of code should be equivalent to the line of code in your post:
$ch = curl_init($awsUrl);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$xml = curl_exec($ch);
$response = simplexml_load_string($xml);Hope this helps!
Cheers,
David.
Just putting this on my site and I'm getting products with 0.00 value. Is there anyway we can exclude anything with no price?
Also, I have managed to change the layout (through trial and error ) but I haven't been able to make the price bold - is there a way to do this?
I have the price in a column on it's own, so the line is:
print $config_currencyHTML.tapestry_decimalise($item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"]);---------
Jill
Hi Jill,
Products with a zero price can be excluded by adding a check/return at the top of the myAmazonRecordHandler function in amazon.php. If you look for the following code:
function myAmazonRecordHandler($item)
{...and then INSERT on the next line:
if (tapestry_decimalise($item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"])==0.00) return;The best way to bold the price is probably a style attribute on the table cell. To do this, look for the following code around line 32:
print "<td valign='middle' align='center'>";...and REPLACE this with:
print "<td valign='middle' align='center' style='font-weight:bold;'>";Cheers,
David.
what is the delay when fetching results from both amazon and local db (price tapestry db i mean)?
cause i was having problems all the time i had amazon api on cause the request and results would delay the whole search results page and/or product page (in case i did both or either of search results or product)
Hi,
There will be a slight delay caused by the round-trip to the API server; however what you could do, if Amazon products are being displayed at the end of the page; would be to issue a flush() statement immediately before the call to require("amazon.php"); for example:
flush();
require("amazon.php");Bear in mind that if you are using a table design the browser may actually hold back displaying cell contents until the closing table tag has been received...
Hope this helps!
Cheers,
David.
I am having products displayed with prices $0.00. When I click on the product, it has a price on the Amazon Site.
Is there a reason that the prices are not showing correctly for some products?
Hi,
That's interesting that a different price is displayed on the destination that is returned in the API. See this comment above regarding suppressing zero prices as shown in the API; but if you could let me know what search index you are using (if not "Blended"), and the keywords being used in the query I'll run them through my test installation and look at the XML response to see if there is something we should be doing slightly differently (such as looking at a different price field in this instance...)
Cheers,
David.
For anyone else having problems working out why this isn't working for them see the post below from http://www.pricetapestry.com/node/2972
Hi Keeop,
Did you upgrade to the authenticated version from this thread?
As a simple debug exercise to see what is being returned from Amazon (which will normally indicate the problem), look for the following code on line 131:
$url = amazonSign($url,$amazonSecretAccessKey);
...and then ADD the following code on the next line:
$xml = file_get_contents($url);
print $xml;exit();
Cheers,
David.Bingo, I found the issue!
The clocks moved a few weeks back, my server was still running an hour behind, I updated the time on it and it works fine!
Set Date/Time from the command line/SSH:
http://www.cyberciti.biz/faq/howto-set-date-time-from-linux-command-prompt/
Matt
Subtle!
Thanks for pointing that out, Matt!
Cheers,
David.
Hi David
hope your well
was wondering if you could help me, products appearing in the amazon part of the script that cost over £1000 appear wrong
eg: Amazon Price of a product - £1,493.84 - but £1.49 shows
would appreciate your knowledge in fixing this
thanks
Phil Stone
www.buy24-7.net
Hi Phil,
This is happening because Price Tapestry is by default set-up to handle the comma as a decimal point; as it common in some product feeds (particularly in the currencies of countries where a comma is used like a decimal point).
To fix this, look for the following code on line 33:
print $config_currencyHTML.tapestry_decimalise($item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"])."<br />";...and REPLACE this with:
$item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"] =
str_replace(",","",$item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"]);
print $config_currencyHTML.tapestry_decimalise($item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"])."<br />";Cheers,
David.
thanks so much dave!!
Best support I've ever had with any product!!!
thanks
Phil Stone
www.buy24-7.net
Hi David,
Got this mod working nicely... but is it possible if there isn't an image, for a spacer.gif to be used instead?
Hi Jim,
Sure - on line 24 of amazon.php you will find:
print "<img width='80' src='".$item["SMALLIMAGE/URL"]."' />";...REPLACE this with:
if (!$item["SMALLIMAGE/URL"]) $item["SMALLIMAGE/URL"] = "/images/spacer.gif";
print "<img width='80' src='".$item["SMALLIMAGE/URL"]."' />";(i've used /images/ infront of spacer.gif; but if it's in the top level folder just use /spacer.gif)
Cheers,
David.
Hi David, I'm encountering a small problem whilst trying getting my page to validate (XHTML 1.0 Transitional) using the Amazon API mod.
The site was tripping up when the title of an item contained an apostrophe...
To try and fix that I tried to use some hacky code below (eg title=\"".) but now I also have problems when the item title contains a quote (eg. Kiss With a Fist [7" VINYL])
print "<tr>";
print "<td width='40'>";
if (!$item["SMALLIMAGE/URL"]) $item["SMALLIMAGE/URL"] = "/pt/images/spacer-40x40.gif";
print "<a title=\"".$item["ITEMATTRIBUTES/TITLE"]."\" target='_blank' href='".$item["DETAILPAGEURL"]."'><img width='40' height='40' src='".$item["SMALLIMAGE/URL"]."' alt=\"".$item["ITEMATTRIBUTES/TITLE"]."\" /></a>";
print "</td>";
print "<td width='30' valign='middle' align='center'>";
print "<b><a title=\"".$item["ITEMATTRIBUTES/TITLE"]."\" class='bandlink' target='_blank' href='".$item["DETAILPAGEURL"]."'>".$config_currencyHTML.tapestry_decimalise($item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"])."</a></b>";
print "</td>";
print "<td width='224' valign='middle'>";
print "<b><a title=\"".$item["ITEMATTRIBUTES/TITLE"]."\" target='_blank' href='".$item["DETAILPAGEURL"]."'>".$item["ITEMATTRIBUTES/TITLE"]."</a></b>";
print "</td>";
print "</tr>";Is there a way to make the title 'safe' ?
(I assume the Amazon API doesn't render ampersands as & either - is it easy to replace space&space with space&space ?)
thanks :)
Hi Jim,
Where adding "unknown" data into an XHTML attribute; use htmlentities(), for example:
title='".htmlentities($item["ITEMATTRIBUTES/TITLE"],ENT_QUOTES)."'The ENT_QUOTES constant makes sure that both ' and " are encoded.
Hope this helps!
Cheers,
David.
Hi David
trying to tweak the amazon.php script, on some of my site i have specialized products into sub categories eg video games, the problem is on the ds pages, amazon results show xbox and playstation games also, is there anyway i could add text after the keywords eg ds, so that when it searches amazons database it returns the results keywords DS?
regards
Phil Stone
www.buy24-7.net
Hello Phil,
Sure - simply replace the code to require amazon.php with the following, edited as required for each installation:
$q .= " DS";
require("amazon.php");Note the space in front of the keywords to append to $q!
Cheers,
David.
Hello David,
I have installed this script on my website but I am not getting any results whatsoever from Amazon.co.uk
The website is television related and I would imagine there is plenty of related content on Amazon.
I have checked my website search with the same search in Amazon and products do show in Amazon.
My access keys are correct
any ideas?
best regards
David S S
Hi David,
If you're sure everything is correct, the thing to do is to print the response from Amazon to the screen, which will normaly indicate the reason for there being no results. To do this, in place of the following code starting at line 131:
$url = amazonSign($url,$amazonSecretAccessKey);
// fetch the response and parse the results
MagicParser_parse($url,"myAmazonRecordHandler","xml|ITEMSEARCHRESPONSE/ITEMS/ITEM/");Use:
$url = amazonSign($url,$amazonSecretAccessKey);
$xml = file_get_contents($url);
// fetch the response and parse the results
print "<textarea cols='80' rows='4'>".htmlentities($xml)."</textarea>";
MagicParser_parse("string://".$xml,"myAmazonRecordHandler","xml|ITEMSEARCHRESPONSE/ITEMS/ITEM/");Cheers,
David.
Hello David,
I did as you suggested above and the error messages onscreen are as follows:
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/XXXXXXX/public_html/amazon.php on line 132
Warning: file_get_contents(http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&Version=2009-03-01&Operation=ItemSearch&AWSAccessKeyId=XXXXXXXXXXXXXX&AssociateTag=XXXXXXXXX-21&ResponseGroup=Medium&SearchIndex=Electronics&Keywords=Sony+KDL+52V4000&Timestamp=2010-01-07T10:48:49Z&Signature=18CC%2FPRK5QPI%2FzNh33FukoJyUEJLQPm7JKPwSJEdB6k%3D) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/XXXXXXX/public_html/amazon.php on line 132
any ideas?
best regards
David S S
Hi David,
That indicates the fopen()'ing URLs is disabled on your PHP configuration. Now, before contacting your host to see if they would be happy to enable this for you account (I assume that you are running on a shared hosting account rather than VPS / Dedicated server) it's worth trying CURL as an alternative method for retrieving the remote URL. To do this, in place of the original code:
$url = amazonSign($url,$amazonSecretAccessKey);
// fetch the response and parse the results
MagicParser_parse($url,"myAmazonRecordHandler","xml|ITEMSEARCHRESPONSE/ITEMS/ITEM/");Have a go with:
$url = amazonSign($url,$amazonSecretAccessKey);
// fetch the response and parse the results
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec($ch);
MagicParser_parse("string://".$xml,"myAmazonRecordHandler","xml|ITEMSEARCHRESPONSE/ITEMS/ITEM/");Hope this helps!
Cheers,
David.
Hello David,
I tried that and now I am getting
Parse error: syntax error, unexpected T_STRING in /home/xxxxxxx/public_html/amazon.php on line 137
best regards
David S S
Hi David,
Sorry - there was a semi-colon missing from...
$xml = curl_exec($ch);I've corrected the code above also.
Cheers,
David.
Hello David,
Happy New Year!!
All fixed, thank you for your help once again.
Although I have just noticed that the Amazon links do not open in a new window.
Can this be changed?
best regards
David S S
Hi David,
Sure - the link is generated by this code (line 34):
print "<nobr><a href='".$item["DETAILPAGEURL"]."'>More Information</a></nobr>";...simply replace with:
print "<nobr><a target='_BLANK' href='".$item["DETAILPAGEURL"]."'>More Information</a></nobr>";Cheers,
David.
Hi David
Is there a way to search across multiple "SearchIndex" - for my site its not ideal to use blended, but more beneficial to use two or three of the categories.
Thanks
Hi,
Sure - you can specify a comma separated list as the value for searchIndex, e.g.
$url .= "&SearchIndex=Books,DVD,Electronics";Cheers,
David.
Hi David
That didn't seem to work, but I tried
$url .= "&SearchIndex=Books&DVD&Electronics";Which oddly enough works for certain combinations of 2 of the 3 searchindexes, but not for all 3 at the same time (and the order which you enter them also seems to matter)?
Hi,
& is actually significant within a URL - it might be worth trying %20 which url decodes to a space...
$url .= "&SearchIndex=Books%20DVD%20Electronics";Cheers,
David.
Hi David, I have a couple of questions if you have a moment:
I'm trying to implement Amazon results on a new small (~100 products) niche site (powered by Wordpress), alongside PT price comparison results.
Can this Amazon mod be used in conjunction with the pricesExternal.php mod?
I tried putting an extra line in:
require($common_path."amazon.php");
but the q value isn't going to be the same?
Would it be an idea to use the Amazon ASIN as a value instead? (although sometimes there may be multiple ASINs I'd like to pull in)
I guess I could do this another way by using a Custom Field to specify a query that exactly matches Amazon's title - or stick the ASIN(s) into a Custom Field(s)
Do you have any suggestions?
thank you!
Jim
Hi Jim,
The only reason why it won't be working is because of the line to include MagicParser.php in amazon.php. To fix this, in your amazon.php look for the following code at around line 6:
require("includes/MagicParser.php");...and REPLACE that with:
require($common_path."includes/MagicParser.php");(this won't stop it working on your main site as $common_path will be empty)
That should be all it is!
Cheers,
David.
Hi David,
I'm having a bit of trouble getting amazon results to show on my wordpress site. Though results come up fine within PT I seem to be getting this in wordpress:
Fatal error: Cannot redeclare myamazonrecordhandler() (previously declared in /home/xxxxxxx/public_html/buyvuvuzela.org.uk/price_tapestry/amazon.php:9) in /home/xxxxxxx/public_html/buyvuvuzela.org.uk/price_tapestry/amazon.php on line 39
I've placed require($common_path."amazon.php"); at the end of the PricesExternal.php script. Prior to this nothing from amazon.php was appearing in wordpress.
Thanks,
Matt
Hi Mat,
According to that error, amazon.php has already been included - which could happen if you have already called pricesExternal.php on that page. To fix that particular issue; change the require() line in pricesExternal.php to the following:
require($common_path."amazon.php");...however, there is one more change required within amazon.php itself which is the call to include MagicParser.php. Look for the following code at line 6:
require("includes/MagicParser.php");...and REPALCE with:
require($common_path."includes/MagicParser.php");Hope this helps!
Cheers,
David.
hi
can anyone tell me where i find my $amazonAssociateTag ?
paul
Hi David
I've placed require($common_path."amazon.php"); in pricesExternal.php and changed line 6 in amazon.php though I'm still getting the same result. I've also tried other possible solutions from the ebay thread but to no avail. Could there be something else interfering in the process?
Thanks,
Matt
Hi Matt,
If including via pricesExternal.php, in addition replace the following code in amazon.php
require("includes/MagicParser.php");...with:
require($common_path."includes/MagicParser.php");(that won't affect running within the normal Price Tapestry installation as $common_path will be empty)
Cheers,
David.
Hi David,
Yes, I've done this already but it still produces the same result:
Fatal error: Cannot redeclare myamazonrecordhandler() (previously declared in /home/wildhike/xxxxxxxxx/buyvuvuzela.org.uk/shopping/amazon.php:9) in /home/xxxxxxxx/public_html/buyvuvuzela.org.uk/shopping/amazon.php on line 39
It works fine within PT itself. Just doesn't come though to Wordpress.
Thanks,
Matt
Hi Matt,
It sounds like amazon.php is being included more than once...
Can you post the calling code you are using on the page that is displaying the error?
Cheers,
David.
Hi David,
Sure,
<?php
$common_baseHREF = "http://buyvuvuzela.org.uk/shopping/";
$common_path = "/home/wildhike/public_html/buyvuvuzela.org.uk/shopping/";
$_GET["q"] = "ALLI 60MG WEIGHT LOSS AID - 42 CAPSULES";
require($common_path."pricesExternal.php");
?>
Cheers,
Matt
Hi Matt,
Could you email me your pricesExternal.php and amazon.php and if possible a link to the page where the above calling code is running, and I'll check it out...
Cheers,
David.
Hi David,
How can I add an Amazon logo to the amazon table? I've tried to direct a link to the logos directory from amazon.php but cannot get it to pick up the image.
Thanks,
Matt
Hi Matt,
Bear in mind that if you have amazon.php included on Product Pages (or externally) you will need to use the fully qualified path to your logo image - in other words, it must start with "/" so that the browser knows exactly where to find the image. In other words, instead of
<img src='logos/amazon.gif' />...it would need to be:
<img src='/path/to/logos/amazon.gif' />If you're not quite sure; it will be fine using the URL also, for example:
<img src='http://www.yoursite.com/logos/amazon.gif' />Hope this helps!
Cheers,
David.
Hi David,
One last Amazon question...
I've placed a heading within the amazon.php table but i've noticed it doesn't disappear along with the rest of the table when there are no amazon results.
I've tried placing this and other variations at line 126 in amazon.php:
if ($item==("myAmazonRecordHandler")) print "Amazon.co.uk / Amazon Marketplace";
but still the remains. How do I make it act like the rest of the table?
Cheers,
Matt
Hi Matt,
Best thing to do is actually to put the code inside the myAmazonRecordHandler function, it is only on the first call to that function that you know that you actually have products!
Add this code immediately inside the function:
global $amazon_first;
if (!$amazon_first)
{
print "<tr><td>Amazon.co.uk / Amazon Marketplace</td></tr>";
$amazon_first = true;
}(the table HTML is necessary because you are inside the table structure at this point)
Finally, at the very top of the script (line after the opening PHP tag) add:
$amazon_first = false;Cheers,
David.
Hi David,
I've placed the code in but it's not quite working. Its probably the wordpress Thesis theme playing up again as it works fine in PT itself.
Within wordpress Thesis theme the command works on the front page but not on any of the posts. Is there any way of making this command run more than once, so it works in the posts too?
Cheers,
Matt
Hello Matt,
That sounds like it's being included multiple times, and therefore the require() statements and the amazon_ functions themselves will be failing because they already exist / have been included.
Can you email me your amazon.php and I'll modify it to use require_once() and function_exists() to ensure that it can be called multiple times on one page...
Cheers,
David.
Hi David,
Is there a way to incorporate the Amazon products into the pricing tables to show a direct product comparison with other merchants? I was hoping to also be able to do product mapping for Amazon products and filtering like I'd be able to do with any other merchant. Any of this possible?
Thanks,
Stacy
Hi Stacy,
The main problem with this is not knowing whether a product return from the Amazon API is definitely the same product as is being featured on the page, so you could end up not comparing like for like. If you could email me with links to your existing Amazon API implementation i'll have a look at how it's working and see if it would be possible, maybe using the SKU/ISBN lookup...
Cheers,
David.
--
PriceTapestry.com
Hi David
I had the idea that I could have an amzonExternal file which I could call on to give me just amazon results on one external page.
I thought it might also be useful to have a selection of these files to search individual index values such as 'toys' 'electronics' and so on to make the results more precise?
Since the ebayExternal file works so well in a similar way I thought it would be a simple matter of changing:
require("includes/MagicParser.php");
to
require($common_path."includes/MagicParser.php");
and then calling
$common_path."amazonExternal.php"
on the page I wanted it?
Alas this didn't work - I am using the curl version btw and have tested that this does work when used as it was originally intended in amazon.php - it's just my external version that doesn't work?
Have I missed something or is it not so simple to achieve this?
Thanks
Hi Darren,
That should work fine - have you set a $_GET["q"] value in your calling code before calling require($common_path."ebayExternal.php"); ?
That might be all it is; if you're not sure, if you could email me both your amazonExternal.php and ebayExternal.php and an example of the calling code being used for each I'll check it out...
Cheers,
David.
--
PriceTapestry.com
Yeah, tried that. I've used the same calling code and just changed amazonExternal to ebayExternal and it works fine?
I'll email you the files - thanks.
No probs Darren - will take a look as soon as I receive the files...
Cheers,
David.
--
PriceTapestry.com
Where can I find in the my account "$amazonAssociateTag"? an example of how it should be?
Thanks!
Hello framor,
Your $amazonAssociateTag is found in a separate place to your Amazon Web Service access keys. You need to either create an associate account, or if you already have one login to your account at the appropriate Amazon domain you are (or wish) to be an affiliate of (.co.uk / .com (US) / .de / .jp) and then after logging in your will see your Associate Tag displayed in the top left corner of the screen.
They normally have the format something like
yourdomainAB-21Cheers,
David.
--
PriceTapestry.com
How to get search results from amazon.it (italian) in English instead?
Thanks!
Hello framor,
I've had a look at the request parameters and there doesn't seem to be a parameter to specify the language of the response i'm afraid.
Cheers,
David.
--
PriceTapestry.com
Hi David,
How do I go about setting it up so that if there are no Amazon results shown, it won't load an empty table. I know you can't see it unless you look at the source of the site, but I'd prefer it not to show. Then I can get the Also from Amazon to only show if there's a result to actually see. (this is using the standard Amazon.php file, not the one you edited for me a few weeks ago to show exact matches only).
Cheers, Ben
Hi Bem,
No problem - from amazon.php, CUT the following lines beginning at line 118:
// start the table
print "<div class='searchresults'>";
print "<table width='100%'>";Now look for the following code towards the top of the myAmazonRecordHandler function (line 15):
$description = "";...and REPLACE with:
$description = "";
if (!$amazonItemCount)
{
// start the table
print "<div class='searchresults'>";
print "<table width='100%'>";
}Finally, look for the following code towards the end of the script, beginning at line 134:
// end the table
print "</table>";
print "</div>";...and REPLACE with:
if ($amazonItemCount)
{
// end the table
print "</table>";
print "</div>";
}That should do the trick!
Cheers,
David.
--
PriceTapestry.com
That works perfectly, thanks David. I knew that I needed to use "if (!$amazonItemCount)" but couldn't get it to work... turns out that I was using it in the wrong place completely. You got it perfect though, cheers. Really appreciate it.
Ben
Thanks for releasing this. When I search for products I am only seeing 4 items from amazon. At the top of the search results screen it says that no items have been found oddly enough. Any ideas?