Using the Amazon Web Service

To get started with creating a developers account, visit the Amazon Web Service (AWS) page at www.amazon.com/gp/aws/landing.html.

| : j j'^J'j* Be sure to activate the account via e-mail before you begin to use it.

The AWS is set up to be accessed from different mediums. The format used for this example is Representational State Transfer (REST), which is basically a formatted URL with all of the necessary information provided in GET format.

Here is a sample request sent to Amazon, as shown in Figure 12.4, to return information about possible book matches for a keyword or series of keywords.

http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWS AccessKeyId={AWS_ACCESS_KEY}&Operation=ItemSearch&SearchIndex= Books&ResponseGroup=Medium&Keywords={SEARCH_TERMS}

The AWS_ACCESS_KEY is the access id that is provided by Amazon, and the SEARCH_TERMS would be the keyword(s) that are passed along for searching.

As you may have noticed, the XML response from Amazon is fairly complex. However, for this example the focus will be on the book title, author, and thumbnail path. Amazon is actually very nice to provide the amount of detail it does. You can build some pretty interesting applications with the AWS system.

FIGURE 12.4

Here is the XML response from Amazon, after a search for "PHP".

File Edit View History Bookmarks Tools Help lift I

3.1.103/clien1s/BoQk/RedStat/Examples/ch%2D11/amazQnSearch/1

u http://192.168...php?terms=php U & Download Free Trial: Charles

< T otaIRe suits >560</T otaIRe suits >

< T otalPage s> 5 6 </T otalPages > - <Item>

<ASIN>0596006810</ASIN>

- <DetailPageURL>

http ://www. amazon. com/gp/r e dire ct. html% 3FASIN=0596006810%26tag=ws% 2 61c o de=xm2% 2 6 cID=2025% 2 6 ccmID=165953% 2 61oc atLon=/o/ASHS] </D etailPagelTRL > <SalesRank>4915</SalesRank>

http ://ecx. image s-amazon. com/images/Cl lYyXA.3 f02L.jpg <fURL>

<Height llnits="pixels" >75 </Height> < Width Units—'pixels" >57</Width> </Sma]Hmage>

http://ecx.im.ages-amazon. com/images/I/216XPVBeygL.jpg

<Height Units="pixels"> 160</Height> <Width Units—'pixels" >122</Width> </Me diuinlmage>

- <LargeImage>

http://ecK. image s - amazon. c om/images/F51 vMTO -XG2L.jpg </URL>

<Height Units—'pixels ">500</Height> <Width Units—'pixels" >381 </Width> </LargeImage>

In fact, the URL sent to Amazon can be modified to search for different items or subjects all together. The AWS is set up to even return valid error messages similar to this one if you don't provide an operation parameter.

AWS.InvalidOperationParameterThe Operation parameter is invalid. Please modify the Operation parameter and retry. Valid values for the Operation parameter include TagLookup, ListLookup, CartGet, SellerListingLookup, CustomerContentLookup, ItemLookup, SimilarityLookup, SellerLookup, ItemSearch, VehiclePartLookup, BrowseNodeLookup, CartModify, ListSearch, CartClear...

The search system offers a lot of types and modifiers, and you don't have to rely on this "create an error" concept to see what is available. Amazon happens to provide very robust documentation in the developer's center. Log in for access.

0 0

Post a comment

  • Receive news updates via email from this site