1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.service.amazon">
4 <title>Zend_Service_Amazon</title>
6 <sect2 id="zend.service.amazon.introduction">
7 <title>Introduction</title>
10 <classname>Zend_Service_Amazon</classname> is a simple <acronym>API</acronym> for using
11 Amazon web services. <classname>Zend_Service_Amazon</classname> has two
12 <acronym>API</acronym>s: a more traditional one that follows Amazon's own
13 <acronym>API</acronym>, and a simpler "Query <acronym>API</acronym>" for constructing
14 even complex search queries easily.
18 <classname>Zend_Service_Amazon</classname> enables developers to retrieve information
19 appearing throughout Amazon.com web sites directly through the Amazon Web Services
20 <acronym>API</acronym>. Examples include:
25 Store item information, such as images, descriptions, pricing, and more
29 <listitem><para>Customer and editorial reviews</para></listitem>
30 <listitem><para>Similar products and accessories</para></listitem>
31 <listitem><para>Amazon.com offers</para></listitem>
32 <listitem><para>ListMania lists</para></listitem>
37 In order to use <classname>Zend_Service_Amazon</classname>, you should already have an
38 Amazon developer <acronym>API</acronym> key aswell as a secret key. To get a key and for
39 more information, please visit the <ulink url="http://aws.amazon.com/">Amazon Web
40 Services</ulink> web site. As of August 15th, 2009 you can only use the Amazon
41 Product Advertising <acronym>API</acronym> through
42 <classname>Zend_Service_Amazon</classname>, when specifying the additional secret key.
46 <title>Attention</title>
49 Your Amazon developer <acronym>API</acronym> and secret keys are linked to your
50 Amazon identity, so take appropriate measures to keep them private.
54 <example id="zend.service.amazon.introduction.example.itemsearch">
55 <title>Search Amazon Using the Traditional API</title>
58 In this example, we search for <acronym>PHP</acronym> books at Amazon and loop
59 through the results, printing them.
62 <programlisting language="php"><![CDATA[
63 $amazon = new Zend_Service_Amazon('AMAZON_API_KEY', 'US', 'AMAZON_SECRET_KEY');
64 $results = $amazon->itemSearch(array('SearchIndex' => 'Books',
65 'Keywords' => 'php'));
66 foreach ($results as $result) {
67 echo $result->Title . '<br />';
72 <example id="zend.service.amazon.introduction.example.query_api">
73 <title>Search Amazon Using the Query API</title>
76 Here, we also search for <acronym>PHP</acronym> books at Amazon, but we instead use
77 the Query <acronym>API</acronym>, which resembles the Fluent Interface design
81 <programlisting language="php"><![CDATA[
82 $query = new Zend_Service_Amazon_Query('AMAZON_API_KEY',
85 $query->category('Books')->Keywords('PHP');
86 $results = $query->search();
87 foreach ($results as $result) {
88 echo $result->Title . '<br />';
94 <sect2 id="zend.service.amazon.countrycodes">
95 <title>Country Codes</title>
98 By default, <classname>Zend_Service_Amazon</classname> connects to the United States
99 ("<code>US</code>") Amazon web service. To connect from a different country, simply
100 specify the appropriate country code string as the second parameter to the constructor:
103 <example id="zend.service.amazon.countrycodes.example.country_code">
104 <title>Choosing an Amazon Web Service Country</title>
106 <programlisting language="php"><![CDATA[
107 // Connect to Amazon in Japan
108 $amazon = new Zend_Service_Amazon('AMAZON_API_KEY', 'JP', 'AMAZON_SECRET_KEY');
113 <title>Country codes</title>
116 Valid country codes are: <code>CA</code>, <code>DE</code>, <code>FR</code>,
117 <code>JP</code>, <code>UK</code>, and <code>US</code>.
122 <sect2 id="zend.service.amazon.itemlookup">
123 <title>Looking up a Specific Amazon Item by ASIN</title>
126 The <methodname>itemLookup()</methodname> method provides the ability to fetch a
127 particular Amazon item when the <acronym>ASIN</acronym> is known.
130 <example id="zend.service.amazon.itemlookup.example.asin">
131 <title>Looking up a Specific Amazon Item by ASIN</title>
133 <programlisting language="php"><![CDATA[
134 $amazon = new Zend_Service_Amazon('AMAZON_API_KEY', 'US', 'AMAZON_SECRET_KEY');
135 $item = $amazon->itemLookup('B0000A432X');
140 The <methodname>itemLookup()</methodname> method also accepts an optional second
141 parameter for handling search options. For full details, including a list of available
142 options, please see the <ulink
143 url="http://www.amazon.com/gp/aws/sdk/main.html/103-9285448-4703844?s=AWSEcommerceService&v=2005-10-05&p=ApiReference/ItemLookupOperation">relevant
144 Amazon documentation</ulink>.
148 <title>Image information</title>
151 To retrieve images information for your search results, you must set
152 <code>ResponseGroup</code> option to <code>Medium</code> or <code>Large</code>.
157 <sect2 id="zend.service.amazon.itemsearch">
158 <title>Performing Amazon Item Searches</title>
161 Searching for items based on any of various available criteria are made simple using the
162 <methodname>itemSearch()</methodname> method, as in the following example:
165 <example id="zend.service.amazon.itemsearch.example.basic">
166 <title>Performing Amazon Item Searches</title>
168 <programlisting language="php"><![CDATA[
169 $amazon = new Zend_Service_Amazon('AMAZON_API_KEY', 'US', 'AMAZON_SECRET_KEY');
170 $results = $amazon->itemSearch(array('SearchIndex' => 'Books',
171 'Keywords' => 'php'));
172 foreach ($results as $result) {
173 echo $result->Title . '<br />';
178 <example id="zend.service.amazon.itemsearch.example.responsegroup">
179 <title>Using the ResponseGroup Option</title>
182 The <code>ResponseGroup</code> option is used to control the specific information
183 that will be returned in the response.
186 <programlisting language="php"><![CDATA[
187 $amazon = new Zend_Service_Amazon('AMAZON_API_KEY', 'US', 'AMAZON_SECRET_KEY');
188 $results = $amazon->itemSearch(array(
189 'SearchIndex' => 'Books',
191 'ResponseGroup' => 'Small,ItemAttributes,Images,SalesRank,Reviews,' .
192 'EditorialReview,Similarities,ListmaniaLists'
194 foreach ($results as $result) {
195 echo $result->Title . '<br />';
201 The <methodname>itemSearch()</methodname> method accepts a single array parameter for
202 handling search options. For full details, including a list of available options, please
204 url="http://www.amazon.com/gp/aws/sdk/main.html/103-9285448-4703844?s=AWSEcommerceService&v=2005-10-05&p=ApiReference/ItemSearchOperation">relevant
205 Amazon documentation</ulink>
211 linkend="zend.service.amazon.query"><classname>Zend_Service_Amazon_Query</classname></link>
212 class is an easy to use wrapper around this method.
217 <sect2 id="zend.service.amazon.query">
218 <title>Using the Alternative Query API</title>
220 <sect3 id="zend.service.amazon.query.introduction">
221 <title>Introduction</title>
224 <classname>Zend_Service_Amazon_Query</classname> provides an alternative
225 <acronym>API</acronym> for using the Amazon Web Service. The alternative
226 <acronym>API</acronym> uses the Fluent Interface pattern. That is, all calls can be
227 made using chained method calls. (e.g., <code>$obj->method()->method2($arg)</code>)
231 The <classname>Zend_Service_Amazon_Query</classname> <acronym>API</acronym> uses
232 overloading to easily set up an item search and then allows you to search based upon
233 the criteria specified. Each of the options is provided as a method call, and each
234 method's argument corresponds to the named option's value:
237 <example id="zend.service.amazon.query.introduction.example.basic">
238 <title>Search Amazon Using the Alternative Query API</title>
241 In this example, the alternative query <acronym>API</acronym> is used as a
242 fluent interface to specify options and their respective values:
245 <programlisting language="php"><![CDATA[
246 $query = new Zend_Service_Amazon_Query('MY_API_KEY', 'US', 'AMAZON_SECRET_KEY');
247 $query->Category('Books')->Keywords('PHP');
248 $results = $query->search();
249 foreach ($results as $result) {
250 echo $result->Title . '<br />';
255 This sets the option <code>Category</code> to "Books" and <code>Keywords</code>
260 For more information on the available options, please refer to the <ulink
261 url="http://www.amazon.com/gp/aws/sdk/main.html/102-9041115-9057709?s=AWSEcommerceService&v=2005-10-05&p=ApiReference/ItemSearchOperation">relevant
262 Amazon documentation</ulink>.
268 <sect2 id="zend.service.amazon.classes">
269 <title>Zend_Service_Amazon Classes</title>
272 The following classes are all returned by <link
273 linkend="zend.service.amazon.itemlookup"><methodname>Zend_Service_Amazon::itemLookup()</methodname></link>
275 linkend="zend.service.amazon.itemsearch"><methodname>Zend_Service_Amazon::itemSearch()</methodname></link>:
281 linkend="zend.service.amazon.classes.item"><classname>Zend_Service_Amazon_Item</classname></link>
288 linkend="zend.service.amazon.classes.image"><classname>Zend_Service_Amazon_Image</classname></link>
295 linkend="zend.service.amazon.classes.resultset"><classname>Zend_Service_Amazon_ResultSet</classname></link>
302 linkend="zend.service.amazon.classes.offerset"><classname>Zend_Service_Amazon_OfferSet</classname></link>
309 linkend="zend.service.amazon.classes.offer"><classname>Zend_Service_Amazon_Offer</classname></link>
316 linkend="zend.service.amazon.classes.similarproduct"><classname>Zend_Service_Amazon_SimilarProduct</classname></link>
323 linkend="zend.service.amazon.classes.accessories"><classname>Zend_Service_Amazon_Accessories</classname></link>
330 linkend="zend.service.amazon.classes.customerreview"><classname>Zend_Service_Amazon_CustomerReview</classname></link>
337 linkend="zend.service.amazon.classes.editorialreview"><classname>Zend_Service_Amazon_EditorialReview</classname></link>
344 linkend="zend.service.amazon.classes.listmania"><classname>Zend_Service_Amazon_ListMania</classname></link>
350 <sect3 id="zend.service.amazon.classes.item">
351 <title>Zend_Service_Amazon_Item</title>
354 <classname>Zend_Service_Amazon_Item</classname> is the class type used to represent
355 an Amazon item returned by the web service. It encompasses all of the items
356 attributes, including title, description, reviews, etc.
359 <sect4 id="zend.service.amazon.classes.item.asxml">
360 <title>Zend_Service_Amazon_Item::asXML()</title>
365 <methodname>asXML</methodname>
370 <para>Return the original <acronym>XML</acronym> for the item</para>
373 <sect4 id="zend.service.amazon.classes.item.properties">
374 <title>Properties</title>
377 <classname>Zend_Service_Amazon_Item</classname> has a number of properties
378 directly related to their standard Amazon <acronym>API</acronym> counterparts.
381 <table id="zend.service.amazon.classes.item.properties.table-1">
382 <title>Zend_Service_Amazon_Item Properties</title>
389 <entry>Description</entry>
395 <entry><acronym>ASIN</acronym></entry>
396 <entry>string</entry>
397 <entry>Amazon Item ID</entry>
401 <entry>DetailPageURL</entry>
402 <entry>string</entry>
403 <entry>URL to the Items Details Page</entry>
407 <entry>SalesRank</entry>
409 <entry>Sales Rank for the Item</entry>
413 <entry>SmallImage</entry>
414 <entry>Zend_Service_Amazon_Image</entry>
415 <entry>Small Image of the Item</entry>
419 <entry>MediumImage</entry>
420 <entry>Zend_Service_Amazon_Image</entry>
421 <entry>Medium Image of the Item</entry>
425 <entry>LargeImage</entry>
426 <entry>Zend_Service_Amazon_Image</entry>
427 <entry>Large Image of the Item</entry>
431 <entry>Subjects</entry>
433 <entry>Item Subjects</entry>
437 <entry>Offers</entry>
441 linkend="zend.service.amazon.classes.offerset">Zend_Service_Amazon_OfferSet</link></code>
444 <entry>Offer Summary and Offers for the Item</entry>
448 <entry>CustomerReviews</entry>
452 Customer reviews represented as an array of <code><link
453 linkend="zend.service.amazon.classes.customerreview">Zend_Service_Amazon_CustomerReview</link></code>
459 <entry>EditorialReviews</entry>
463 Editorial reviews represented as an array of <code><link
464 linkend="zend.service.amazon.classes.editorialreview">Zend_Service_Amazon_EditorialReview</link></code>
470 <entry>SimilarProducts</entry>
474 Similar Products represented as an array of <code><link
475 linkend="zend.service.amazon.classes.similarproduct">Zend_Service_Amazon_SimilarProduct</link></code>
481 <entry>Accessories</entry>
485 Accessories for the item represented as an array of <code><link
486 linkend="zend.service.amazon.classes.accessories">Zend_Service_Amazon_Accessories</link></code>
492 <entry>Tracks</entry>
496 An array of track numbers and names for Music CDs and
497 <constant>DVD</constant>s
502 <entry>ListmaniaLists</entry>
506 Item related Listmania Lists as an array of <code><link
507 linkend="zend.service.amazon.classes.listmania">Zend_Service_Amazon_ListmainList</link></code>
513 <entry>PromotionalTag</entry>
514 <entry>string</entry>
515 <entry>Item Promotional Tag</entry>
522 <link linkend="zend.service.amazon.classes">Back to Class List</link>
527 <sect3 id="zend.service.amazon.classes.image">
528 <title>Zend_Service_Amazon_Image</title>
531 <classname>Zend_Service_Amazon_Image</classname> represents a remote Image for a
535 <sect4 id="zend.service.amazon.classes.image.properties">
536 <title>Properties</title>
538 <table id="zend.service.amazon.classes.image.properties.table-1">
539 <title>Zend_Service_Amazon_Image Properties</title>
546 <entry>Description</entry>
553 <entry>Zend_Uri</entry>
554 <entry>Remote <acronym>URL</acronym> for the Image</entry>
558 <entry>Height</entry>
560 <entry>The Height of the image in pixels</entry>
566 <entry>The Width of the image in pixels</entry>
573 <link linkend="zend.service.amazon.classes">Back to Class List</link>
578 <sect3 id="zend.service.amazon.classes.resultset">
579 <title>Zend_Service_Amazon_ResultSet</title>
582 <classname>Zend_Service_Amazon_ResultSet</classname> objects are returned by <link
583 linkend="zend.service.amazon.itemsearch">Zend_Service_Amazon::itemSearch()</link>
584 and allow you to easily handle the multiple results returned.
588 <title>SeekableIterator</title>
591 Implements the <code>SeekableIterator</code> for easy iteration (e.g. using
592 <code>foreach</code>), as well as direct access to a specific result using
593 <methodname>seek()</methodname>.
597 <sect4 id="zend.service.amazon.classes.resultset.totalresults">
598 <title>Zend_Service_Amazon_ResultSet::totalResults()</title>
602 <methodname>totalResults</methodname>
606 <para>Returns the total number of results returned by the search</para>
607 <para><link linkend="zend.service.amazon.classes">Back to Class List</link></para>
611 <sect3 id="zend.service.amazon.classes.offerset">
612 <title>Zend_Service_Amazon_OfferSet</title>
615 Each result returned by <link
616 linkend="zend.service.amazon.itemsearch">Zend_Service_Amazon::itemSearch()</link>
618 linkend="zend.service.amazon.itemlookup">Zend_Service_Amazon::itemLookup()</link>
619 contains a <classname>Zend_Service_Amazon_OfferSet</classname>
620 object through which pricing information for the item can be retrieved.
623 <sect4 id="zend.service.amazon.classes.offerset.parameters">
624 <title>Properties</title>
626 <table id="zend.service.amazon.classes.offerset.parameters.table-1">
627 <title>Zend_Service_Amazon_OfferSet Properties</title>
634 <entry>Description</entry>
640 <entry>LowestNewPrice</entry>
644 Lowest Price for the item in "New" condition
649 <entry>LowestNewPriceCurrency</entry>
650 <entry>string</entry>
651 <entry>The currency for the <code>LowestNewPrice</code></entry>
655 <entry>LowestOldPrice</entry>
659 Lowest Price for the item in "Used" condition
664 <entry>LowestOldPriceCurrency</entry>
665 <entry>string</entry>
666 <entry>The currency for the <code>LowestOldPrice</code></entry>
670 <entry>TotalNew</entry>
674 Total number of "new" condition available for the item
679 <entry>TotalUsed</entry>
683 Total number of "used" condition available for the
689 <entry>TotalCollectible</entry>
693 Total number of "collectible" condition available for
699 <entry>TotalRefurbished</entry>
703 Total number of "refurbished" condition available for
709 <entry>Offers</entry>
713 An array of <classname>Zend_Service_Amazon_Offer</classname>
722 <link linkend="zend.service.amazon.classes">Back to Class List</link>
727 <sect3 id="zend.service.amazon.classes.offer">
728 <title>Zend_Service_Amazon_Offer</title>
731 Each offer for an item is returned as an
732 <classname>Zend_Service_Amazon_Offer</classname> object.
735 <sect4 id="zend.service.amazon.classes.offer.properties">
736 <title>Zend_Service_Amazon_Offer Properties</title>
738 <table id="zend.service.amazon.classes.offer.properties.table-1">
739 <title>Properties</title>
746 <entry>Description</entry>
752 <entry>MerchantId</entry>
753 <entry>string</entry>
754 <entry>Merchants Amazon ID</entry>
758 <entry>MerchantName</entry>
759 <entry>string</entry>
762 Merchants Amazon Name. Requires setting the
763 <code>ResponseGroup</code> option to <code>OfferFull</code> to
768 <entry>GlancePage</entry>
769 <entry>string</entry>
770 <entry>URL for a page with a summary of the Merchant</entry>
774 <entry>Condition</entry>
775 <entry>string</entry>
776 <entry>Condition of the item</entry>
780 <entry>OfferListingId</entry>
781 <entry>string</entry>
782 <entry>ID of the Offer Listing</entry>
788 <entry>Price for the item</entry>
792 <entry>CurrencyCode</entry>
793 <entry>string</entry>
794 <entry>Currency Code for the price of the item</entry>
798 <entry>Availability</entry>
799 <entry>string</entry>
800 <entry>Availability of the item</entry>
804 <entry>IsEligibleForSuperSaverShipping</entry>
805 <entry>boolean</entry>
808 Whether the item is eligible for Super Saver Shipping or not
816 <link linkend="zend.service.amazon.classes">Back to Class List</link>
821 <sect3 id="zend.service.amazon.classes.similarproduct">
822 <title>Zend_Service_Amazon_SimilarProduct</title>
825 When searching for items, Amazon also returns a list of similar products that the
826 searcher may find to their liking. Each of these is returned as a
827 <classname>Zend_Service_Amazon_SimilarProduct</classname> object.
831 Each object contains the information to allow you to make sub-sequent requests to
832 get the full information on the item.
835 <sect4 id="zend.service.amazon.classes.similarproduct.properties">
836 <title>Properties</title>
838 <table id="zend.service.amazon.classes.similarproduct.properties.table-1">
839 <title>Zend_Service_Amazon_SimilarProduct Properties</title>
846 <entry>Description</entry>
852 <entry><acronym>ASIN</acronym></entry>
853 <entry>string</entry>
854 <entry>Products Amazon Unique ID (ASIN)</entry>
859 <entry>string</entry>
860 <entry>Products Title</entry>
867 <link linkend="zend.service.amazon.classes">Back to Class List</link>
872 <sect3 id="zend.service.amazon.classes.accessories">
873 <title>Zend_Service_Amazon_Accessories</title>
876 Accessories for the returned item are represented as
877 <classname>Zend_Service_Amazon_Accessories</classname> objects
880 <sect4 id="zend.service.amazon.classes.accessories.properties">
881 <title>Properties</title>
883 <table id="zend.service.amazon.classes.accessories.properties.table-1">
884 <title>Zend_Service_Amazon_Accessories Properties</title>
891 <entry>Description</entry>
897 <entry><acronym>ASIN</acronym></entry>
898 <entry>string</entry>
899 <entry>Products Amazon Unique ID (ASIN)</entry>
904 <entry>string</entry>
905 <entry>Products Title</entry>
912 <link linkend="zend.service.amazon.classes">Back to Class List</link>
917 <sect3 id="zend.service.amazon.classes.customerreview">
918 <title>Zend_Service_Amazon_CustomerReview</title>
921 Each Customer Review is returned as a
922 <classname>Zend_Service_Amazon_CustomerReview</classname> object.
925 <sect4 id="zend.service.amazon.classes.customerreview.properties">
926 <title>Properties</title>
928 <table id="zend.service.amazon.classes.customerreview.properties.table-1">
929 <title>Zend_Service_Amazon_CustomerReview Properties</title>
936 <entry>Description</entry>
942 <entry>Rating</entry>
943 <entry>string</entry>
944 <entry>Item Rating</entry>
948 <entry>HelpfulVotes</entry>
949 <entry>string</entry>
950 <entry>Votes on how helpful the review is</entry>
954 <entry>CustomerId</entry>
955 <entry>string</entry>
956 <entry>Customer ID</entry>
960 <entry>TotalVotes</entry>
961 <entry>string</entry>
962 <entry>Total Votes</entry>
967 <entry>string</entry>
968 <entry>Date of the Review</entry>
972 <entry>Summary</entry>
973 <entry>string</entry>
974 <entry>Review Summary</entry>
978 <entry>Content</entry>
979 <entry>string</entry>
980 <entry>Review Content</entry>
987 <link linkend="zend.service.amazon.classes">Back to Class List</link>
992 <sect3 id="zend.service.amazon.classes.editorialreview">
993 <title>Zend_Service_Amazon_EditorialReview</title>
996 Each items Editorial Reviews are returned as a
997 <classname>Zend_Service_Amazon_EditorialReview</classname> object
1000 <sect4 id="zend.service.amazon.classes.editorialreview.properties">
1001 <title>Properties</title>
1003 <table id="zend.service.amazon.classes.editorialreview.properties.table-1">
1004 <title>Zend_Service_Amazon_EditorialReview Properties</title>
1011 <entry>Description</entry>
1017 <entry>Source</entry>
1018 <entry>string</entry>
1019 <entry>Source of the Editorial Review</entry>
1023 <entry>Content</entry>
1024 <entry>string</entry>
1025 <entry>Review Content</entry>
1032 <link linkend="zend.service.amazon.classes">Back to Class List</link>
1037 <sect3 id="zend.service.amazon.classes.listmania">
1038 <title>Zend_Service_Amazon_Listmania</title>
1041 Each results List Mania List items are returned as
1042 <classname>Zend_Service_Amazon_Listmania</classname> objects.
1045 <sect4 id="zend.service.amazon.classes.listmania.properties">
1046 <title>Properties</title>
1048 <table id="zend.service.amazon.classes.listmania.properties.table-1">
1049 <title>Zend_Service_Amazon_Listmania Properties</title>
1056 <entry>Description</entry>
1062 <entry>ListId</entry>
1063 <entry>string</entry>
1064 <entry>List ID</entry>
1068 <entry>ListName</entry>
1069 <entry>string</entry>
1070 <entry>List Name</entry>
1077 <link linkend="zend.service.amazon.classes">Back to Class List</link>
1084 vim:se ts=4 sw=4 et: