PHP Classes

Amazon API Access with PHP and XML: A PHP XML class to access Amazon API they released

Recommend this page to a friend!

  Author Author  
Name: Uioreanu Calin <contact>
Classes: 1 package by
Country: Germany Germany
Age: ???
All time rank: 25612 in Germany Germany
Week rank: 170 Up4 in Germany Germany Up

  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  

Now everybody heard of What not everybody knows that Amazon released an API to access its huge catalogs. What this basically means is that each developer can access the information from Amazon following some simple protocols and every site owner can enhance his own website with content and features from Amazon.

The Amazon API comes as a simple Webservice. Here are the first Web services that they have exposed:
- Product Display : The ability to search for and retrieve product information from the catalog.
- Shopping Cart : The ability to add products to shopping carts, wish lists, and registries from third party locations.

No matter of your intentions, you will first need to register and obtain a valid developer token. You can get your token here at this address:

The current listed implementation of Amazon webservices uses Keyword searches. It has basically the same results as searching the books catalog online. As any developer/webmaster can see in the " Web Services Developers Kit v 1.0" document, a lot of other Amazon features are exposed. This would imply extending the base structure I present here.

There are multiple approaches from a developer's point of view. The simplest one deals with SOAP and web services classes already implemented in PHP. You could also extend the PEAR's XMLParser object to parse Amazon results. The reason I did not choose these directions is because they require additional extensions installed with PHP. What I currently use is the XML parsing package that comes embedded in PHP, so it is slightly more general.

What basically happens in this implementation is that the search word entered by the used is embedded into a XML url that is then retrieved from Then PHP builds a nice display for the information received.

I should let the code talk for itself. Here is the main controller, with a small search form for Amazon:

As you see, the actual code is very small. Then here is the class used in the controller to parse the XML returned by Amazon.

Then the configuration file. I need to remember you that you need to change the DEVELOPER_TOKEN constant with the one you will obtain from Amazon. The current license key belongs to me. You also need to change the ASSOCIATE_ID constant with a one from Amazon. You also need to do the same change in the file php9-data-to-html.xsl, the engine for the XSLT transformation.The current constant set belongs to me also.

And here is the layout template used to build the output from the XML document retrieved from Amazon. It is parsed every time a book record is retrieved, so the output rendering is the fastest possible.

And here is the XSLT document used to build the HTML product page document from the XML document retrieved from Amazon.

Here you have the full package zipped.

And of course a demo:

As the project improved a lot during the latest months, I created a freshmeat project here:

and a class collection in the extensive package provided by Manuel Lemos:

Feel free to use it and improve. I am open to suggestions.

The class has been updated to use Amazon Webservices Version 2 (search order, number of results).

  Classes of Uioreanu Calin  >  Amazon API Access with PHP and XML  >  Download Download .zip .tar.gz  >  Support forum Support forum (3)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: Amazon API Access with PHP and XML
Base name: amazon
Description: A PHP XML class to access Amazon API they released
Version: 1.0.0
PHP version: 3
License: The PHP License
All time users: 9306 users
All time rank: 157
Week users: 5 users
Week rank: 164 Down
  Groups   Rate classes User ratings   Trackback  
  Applications   Related pages   Files Files  

Group folder image XML XML parsing and generation View top rated classes
Group folder image E-Commerce Online stores, shopping baskets and payment methods View top rated classes
Group folder image Web services Web data clipping, SOAP or XML-RPC clients and servers View top rated classes

  User ratings  
RatingsUtility Consistency Documentation Examples Tests Videos Overall Rank
All time: Good (83%) Sufficient (71%) - Sufficient (75%) - - Not sure (56%) 1537
Month: Not enough user ratings

  Pages that reference this package  
Getting product feed data from Amazon UK
It sounds like you're having general problems communicating with their SOAP API, which given, is a pain to use...
PHP Tutorials Utopia: 13 Vital PHP skills for every novice PHP developer and solutions
Today, Iím going to write about PHP, The most popular server-side scripting language...

Latest pages that reference packages Latest pages that reference packages

  Applications that use this package  
Add search teasers from Amazon to your site search
This article is intended for every web developer or webmaster interested in having search results as teasers on his search results page. Requirements are small experience with web services, and basic programming skills
Amazon PHP API Demo
A small demo using the light search in Amazon catalog
another site using the Amazon PHP class by Alan Samoun
site for the Earle Baum Center of the Blind (EBC), a nonprofit regional community center, serving the blind and visually impaired from Nothern California.
Camcorders shop
Coming from the same codebase as the digicams shop, a simple camcorders shop is available. Have a look around it
the simplest digicams shop using Amazon API
Doug Sahm dotcom a.k.a Amigos De Musica
A nice dedicated musical shop and not only by Joop Toeset (xscom)
dvd shop
the simplest DVD shop using Amazon API
Garden Grow
a combination of the Amazon API PHP class and PHP Open Directory Project (phpODP). Looks like a perfect match between amazon webservices and another well known PHP Project
Pinhole Visions - The Art of Pinhole Photography
The Pinhole Visions web site exists to support pinhole photography as both an art form and a learning activity. The site uses amazon.php class for the homepage top selling books listing. A cache class by Gregg D. Kemp is active also. Brazil books
Amazon PHP API Demo using also the Smarty templating system in PHP
the simplest shop in the world
shopping site featuring prices and features comparison, easy to use and intuitive categorisation, product reviews and best prices
Top Science Books
the simplest Top Science books shop using Amazon API
the simplest top books shop of the world

Add link image If you know an application of this package, send a message to the author to add a link here.

  Related pages  
digicams shop: the simplest digicams shop using Amazon API PHP Class
live xml feed from amazon using a html caching layer

  Files folder image Files  
File Role Description
Accessible without login Plain text file amazon.php Example controller script Amazon API
Accessible without login Plain text file amazon_class.php Class webservice class definition for Amazon Parser
Accessible without login Plain text file amazon_config.php Conf. configuration variables for Amazon Parser
Accessible without login Plain text file amazon_layout.php Example display template for Amazon API
Plain text file amazon_search_config.php Conf. configuration file for the Amazon search teasers
Plain text file amazon_search_layout.php Example the layout for the Amazon Search teaser
Plain text file amazon_search_teaser.php Example Search teaser in case you want results from Amazon on your site internal search

Install with Composer Install with Composer - Download Download all files: amazon.tar.gz
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.