Zend_Service_AmazonIntroductionZend_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:
In order to use Zend_Service_Amazon, you should already have an Amazon developer API key aswell as a secret key. To get a key and for more information, please visit the » Amazon Web Services web site. As of August 15th, 2009 you can only use the Amazon Product Advertising API through Zend_Service_Amazon, when specifying the additional secret key.
Example #1 Search Amazon Using the Traditional API In this example, we search for PHP books at Amazon and loop through the results, printing them.
Example #2 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
(" Example #3 Choosing an Amazon Web Service Country
Looking up a Specific Amazon Item by ASINThe itemLookup() method provides the ability to fetch a particular Amazon item when the ASIN is known. Example #4 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 SearchesSearching for items based on any of various available criteria are made simple using the itemSearch() method, as in the following example: Example #5 Performing Amazon Item Searches
Example #6 Using the ResponseGroup Option
The
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 Tip
The Zend_Service_Amazon_Query class is an easy to use wrapper around this method. Using the Alternative Query APIIntroduction
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., 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: Example #7 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 For more information on the available options, please refer to the » relevant Amazon documentation. Zend_Service_Amazon ClassesThe following classes are all returned by Zend_Service_Amazon::itemLookup() and Zend_Service_Amazon::itemSearch(): Zend_Service_Amazon_ItemZend_Service_Amazon_Item is the class type used to represent an Amazon item returned by the web service. It encompasses all of the items attributes, including title, description, reviews, etc. Zend_Service_Amazon_Item::asXML()
string
asXML
( void
Return the original XML for the item PropertiesZend_Service_Amazon_Item has a number of properties directly related to their standard Amazon API counterparts.
Zend_Service_Amazon_ImageZend_Service_Amazon_Image represents a remote Image for a product. Properties
Zend_Service_Amazon_ResultSetZend_Service_Amazon_ResultSet objects are returned by Zend_Service_Amazon::itemSearch() and allow you to easily handle the multiple results returned.
Zend_Service_Amazon_ResultSet::totalResults()
int
totalResults
( void
Returns the total number of results returned by the search Zend_Service_Amazon_OfferSetEach result returned by Zend_Service_Amazon::itemSearch() and Zend_Service_Amazon::itemLookup() contains a Zend_Service_Amazon_OfferSet object through which pricing information for the item can be retrieved. Properties
Zend_Service_Amazon_OfferEach offer for an item is returned as an Zend_Service_Amazon_Offer object. Zend_Service_Amazon_Offer Properties
Zend_Service_Amazon_SimilarProductWhen searching for items, Amazon also returns a list of similar products that the searcher may find to their liking. Each of these is returned as a Zend_Service_Amazon_SimilarProduct object. Each object contains the information to allow you to make sub-sequent requests to get the full information on the item. Properties
Zend_Service_Amazon_AccessoriesAccessories for the returned item are represented as Zend_Service_Amazon_Accessories objects Properties
Zend_Service_Amazon_CustomerReviewEach Customer Review is returned as a Zend_Service_Amazon_CustomerReview object. Properties
Zend_Service_Amazon_EditorialReviewEach items Editorial Reviews are returned as a Zend_Service_Amazon_EditorialReview object Properties
Zend_Service_Amazon_ListmaniaEach results List Mania List items are returned as Zend_Service_Amazon_Listmania objects. Properties
|
|