Zend_Service_Amazon
Introduction
Zend_Service_Amazon is a simple API for using Amazon web services. Zend_Service_Amazon has two APIs: a more traditional one that follows Amazon's own API, and a simpler "Query API" for constructing even complex search queries easily.
Zend_Service_Amazon enables developers to retrieve information appearing throughout Amazon.com web sites directly through the Amazon Web Services API. Examples include:
- Store item information, such as images, descriptions, pricing, and more
- Customer and editorial reviews
- Similar products and accessories
- Amazon.com offers
- ListMania lists
In order to use Zend_Service_Amazon, you should already have an Amazon developer API key. To get a key and for more information, please visit the Amazon Web Services web site.
|
Your Amazon developer API key is linked to your Amazon identity, so take appropriate measures to keep your API key private. |
Search Amazon Using the Traditional API
In this example, we search for PHP books at Amazon and loop through the results, printing them.
Search Amazon Using the Query API
Here, we also search for PHP books at Amazon, but we instead use the Query API, which resembles the Fluent Interface design pattern.
Country Codes
By default, Zend_Service_Amazon connects to the United States ("US") Amazon web service. To connect from a different country, simply specify the appropriate country code string as the second parameter to the constructor:
Choosing an Amazon Web Service Country
|
Valid country codes are: CA, DE, FR, JP, UK, and US. |
Looking up a Specific Amazon Item by ASIN
The itemLookup() method provides the ability to fetch a particular Amazon item when the ASIN is known.
Looking up a Specific Amazon Item by ASIN
The itemLookup() method also accepts an optional second parameter for handling search options. For full details, including a list of available options, please see the relevant Amazon documentation.
Performing Amazon Item Searches
Searching for items based on any of various available criteria are made simple using the itemSearch() method, as in the following example:
Performing Amazon Item Searches
The itemSearch() method accepts a single array parameter for handling search options. For full details, including a list of available options, please see the relevant Amazon documentation
|
The Zend_Service_Amazon_Query class is an easy to use wrapper around this method. |
Using the Alternative Query API
Introduction
Zend_Service_Amazon_Query provides an alternative API for using the Amazon Web Service. The alternative API uses the Fluent Interface pattern. That is, all calls can be made using chained method calls. (e.g., $obj->method()->method2($arg))
The Zend_Service_Amazon_Query API uses overloading to easily set up an item search and then allows you to search based upon the criteria specified. Each of the options is provided as a method call, and each method's argument corresponds to the named option's value:
Search Amazon Using the Alternative Query API
In this example, the alternative query API is used as a fluent interface to specify options and their respective values:
This sets the option Category to "Books" and Keywords to "PHP".
For more information on the available options, please refer to the relevant Amazon documentation.
Comments placed in the "dev" version of the wiki would be reviewed by all documentation/translation team members. Only "good" comments would be included in the production version of the manual.
Other "good" comments might become included in the text of the page above, provided we have a CLA, or the comments might yield ideas to the documentation team, and thereby become "incorporated" into the wiki page.
ZF Home Page
Code Browser
Wiki Dashboard
Example comment.