Amazon Associates Web Service Simple Store in PHP

items>Amazon Associates Web Service Simple Store in PHP
Community Contributed Software

  • Amazon Web Services provides links to these packages as a convenience for our customers, but software not authored by an "@AWS" account has not been reviewed or screened by AWS.
  • Please review this software to ensure it meets your needs before using it.

This is a simple PHP 5 application demonstrating the basics of how to interact with Amazon Associates Web Service.


Submitted By: Philip@AWS
AWS Products Used: Amazon Associates Web Service
Language(s): PHP
License: Apache License 2.0
Created On: November 16, 2006 12:21 AM GMT
Last Updated: October 21, 2010 10:27 PM GMT

About This Sample

  • Based on the 2006-09-11 API version.
  • This application is meant to demonstrate the ItemSearch, ItemLookup, CartCreate, CartAdd, and CartModify operations. It is not intended to be be comprehensive example of how to build an e-commerce store. For example, on an ItemSearch by Keywords, this sample only returns items that are for sale by Amazon (as opposed to other Merchants).
  • This sample was tested on PHP 5.1.4.

What's New

  • 2007-04-06: This sample now presents a "See Cart Contents" link when items are in the shopper's cart. Previously, a shopper could only see cart contents upon adding an item to the cart.


  • You must have a valid Amazon Web Services developer account. (You can create one here:

Running the Sample

  1. Replace YourAccessKeyIdHere wih your AWS Access Key Id near the top of the simplestore.php file.
  2. [Optional] Replace YourAssociateTagHere with your Associate Tag near the top of the simplestore.php file. This needs to be done if you want to earn referral fees for sales you generate. You can learn more about our associates program here.
  3. To run the sample, put SimpleStore.php in your root directrory and load SimpleStore.php?Action=Search in your browser.


Price Comparison Script
I have seen AxisITP already have a script which work with the Amazon as well as thousands of other merchants the script is a price comparison script:
pricecomparisonscript on October 19, 2010 2:28 PM GMT
Should be updated or removed
It's been 11 months since this code sample actually worked. It stopped working on August 15, 2009 when signed requests became mandatory. If Amazon doesn't want to update it (or lacks the resources to do so) it should be removed. Same thing with the API documentation, the samples don't work because they don't include signing. Even the documentation dated two and a half months after signing became mandatory have non-signed samples that don't work.
H. Hankins on July 20, 2010 6:20 PM GMT
Not Working Poor Example
Is this working example? Every time No matches found. No Result Sometime - SignatureDoesNotMatchThe request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.f864547a-7a73-43ef-8f3f-7c8a5b84c2c7 Do not post example if they are not working for users OR make good documentation
appandyaap on June 8, 2010 7:04 PM GMT
doesnt work
I get the undefined variable warnings for CartId and HMAC which I am ignoring. I've tried a few searches and no results are returned.
mccurrystephen on June 6, 2010 9:53 PM GMT
No Matches Found
i got the result no matches found, i followed the guidelines yet its not working for me. Please Help!!
niteshabcabc on March 21, 2010 5:44 PM GMT
Problems running example
It seems to load fine for me but anytime I search for anything I don't get any results back. I'm not sure why this is. Could it have anything to do with the proxy settings? If so, how would you go about setting the proxy in this example?
cis123 on February 9, 2010 3:11 PM GMT
Can't Get It To Work
Tried everything but can't get it to return results. No matter what you search results it just returns no matches found.
vgtradez on January 30, 2010 7:25 PM GMT
error message
I get a, No matches found error message no matter what I search for?
jester joker on May 20, 2009 4:12 PM GMT
Thanks for sharing
Works great. Just needed to change a couple of things that are already covered in the thread. Thanks!
cschuermyer on May 13, 2009 4:29 AM GMT
Works perfectly
Works perfectly, without a trouble. Easy to setup. Just add your associates id and upload, just like that.
B. Truong on April 10, 2009 5:54 AM GMT
works right out of the box
madplay on January 29, 2009 4:49 AM GMT
Issue with Operation
Loaded the php file on a webserver and it displays without issue but any search never returns any results. I entered my Access Key ID where needed and activated it from the Amazon email. No errors at any point just no results from the search. Thanks
jon027 on December 18, 2008 9:47 PM GMT
worked awesome.
The only thing i had to do was enable "php_curl" library in wamp and restart all the services.
matkahtml on July 13, 2008 3:40 PM GMT
PHP5 or above ONLY
Ken Torimaru, you're not using PHP5, see comments below + requirements
Russ on April 10, 2008 8:25 PM GMT
Error suppression
For people who are worried about the error message on running this script simply add error_reporting(0); enclosed in PHP start/end tags at the top of the script. The error messages are warnings because the variables are not populated until the first search is executed. In any case, remember that this is a basically a demo script to show how ECS can be accessed using PHP. If error messages frighten you it's probably better to learn a bit more PHP :) (4 stars because of the lack of documentation/guidance for PHP neophytes.)
AdBabel on October 13, 2007 5:08 AM GMT
Very Impressed
As with most pieces of code that try and help you explain things, this does a great job, I don't think by any means was this package meant to be dropped to start everyone with a very involved system, which is exactly why its a 'simple store' and has little to no graphics. The lesson is to see how to interact with the Amazon API, and it does a great job. I saw a review that said 'Why would I only want to see the high price?' You could explore more with the API and do whatever you want. There is a lot this didn't go into, but again that is why it was labeled 'simple'. Great job!!
conrad10781 on October 8, 2007 12:29 PM GMT
Thanks for this script
I tried to implement my own script at the beginning but could not obtain something good as I would have expected. I then decided to try this SimpleStore.php script. I was very someone added this. Nevertheless I firstly add this problem: The CurlInt() php function was said to be unavailable -> had to have Apache load the module (php.ini) on the server. This solved one of the problem. Then I tried the SimpleStore.php again and it show me those errors: Notice: Undefined variable: CartId in ...\SimpleStore.php on line 30 Notice: Undefined variable: HMAC in ...\SimpleStore.php on line 32 What should I do for those variables? Finally, I dont know if thi is related with the undefined variable problem, but whatever the keywords or the category I choose, the result will always be "No match Found". May someone help me please? Hidetaka
hidetaka2 on October 6, 2007 7:39 PM GMT
Worked Fine but...
Not what I expected. Why would I only want to see the high price? I want the low price too. Chris
Christopher Dixon on September 22, 2007 11:24 AM GMT
work perfectly on php5
very good example for understanding the php api. on September 15, 2007 5:54 PM GMT
PHP Code
there is no suficient documentation for implementing it.
prince1980 on September 7, 2007 10:13 AM GMT
Doesn't work for me
I don't see how this script can work properly. $CartID and $HMAC are not getting passed around correctly. For example, right at the top it prints the FORM containing hidden INPUT fields with VALUEs set from variables $CartId and $HMAC. Problem is - those 2 variables are not retrieved until code that comes *after* the print() call.
Doctor 3D on September 5, 2007 4:43 PM GMT
This is great! Works perfectly with php 5! Thanks so much!
vernonmorris on August 19, 2007 5:01 PM GMT
Amazon ECS Simple Store in PHP
I have the same error than Toxitalk. What can we do? Thnks
rocasespino on August 7, 2007 5:17 PM GMT
Great start
It really is a great base to work from. I wonder if anyone else has encountered the slightly confusing issue of what happens when you add a second item to the shopping cart? I.e. both disappear!
davidstone78 on July 16, 2007 7:06 PM GMT
nice base
Had some issues with some of the stuff bombing(due to things like type casting needed) but its still VERY slow to this just expected from amazon's api or is it the fundamentals of the script and the way it works?
crudpuppy on July 15, 2007 4:11 AM GMT
Phenomenal. Works like a charm, and like some of the other comments: simple, yet very powerful.
kevchuey on June 8, 2007 4:33 AM GMT
WOW, this worked great on me. Thanks, it is very simple but very powerfull. I'm surprised. :D
centerax on May 3, 2007 1:22 AM GMT
Ive got PHP5 but why do I get errors?
I get a number of errors to do with uninitialised variables and undefined index's (CartId and HMAC) Help.
toxitalk on April 26, 2007 11:00 AM GMT
Error Message
... for your information ... putting something into the shopping cart and trying to remove it again gives you a nice error message: Invalid argument supplied for foreach() on line 218
Johannes P. Wilbrand on March 9, 2007 4:48 PM GMT
Humm, no more informations ?
I wanted to use the search mode, but it isn't as well as i expected : can we have any more informations about products ? Year of publication, editor etc... are usefull. Jk.
aliasjokester on February 16, 2007 8:11 PM GMT
Just what I needed
A good quick script to get in idea of how to use the api.
defrex on February 14, 2007 5:25 PM GMT
PHP5 Solution
This solution is meant for PHP5 & higher. If you are running it on lower versions of PHP, "simplexml_load_string" function would not it is not available in versions lower to PHP5. Regards Arijit
innindia on February 10, 2007 1:48 PM GMT
function simplexml_load_string
The function simplexml_load_string appears to be missing.
Ken Torimaru on February 8, 2007 6:01 PM GMT
We are temporarily not accepting new comments.
©2017, Amazon Web Services, Inc. or its affiliates. All rights reserved.