Amazon Web Services: A Brief Introduction Using PHP

Build the XML Link

Before we receive the XML data, we have to make the appropriate request to AWS by building the XML link. It is essential that you understand how to construct the XML link to access AWS. Building the XML Link is simply a matter of mixing and matching attributes from the XML link template:[Your Associates ID]&dev-t=[Your developer token]&[Search Type]=[Search Term]&mode=books&sort=[Sort]&offer=All&type=[Type]&page=[Page Number]&f=xml

Complicated? Not really, the trick is to simply plug in the appropriate value into the five highlighted attributes. Mixing and matching. The highlighted attributes with their possible values are detailed below:

Search Type
  • AsinSearch
    Search for a single product using the ASIN, Amazon's unique product identifier.

  • AuthorSearch
    Search for books by author.

  • BrowseNodeSearch
    Search for products by BrowseNode category.

  • KeywordSearch
    Search for products by keyword.

Search Term

Search Term is dependant upon the Search Type. If the Search Type is AsinSearch, then Search Term is a product's ASIN. If the Search Type is BrowseNodeSearch, then the Search Term is a category's unique numeric BrowseNode. For a KeywordSearch or AuthorSearch, the Search Term is whatever was entered into the search box or the author's name, respectively.

  • +pmrank
    Items are sorted by featured item, which is determined by Amazon.

  • +salesrank
    Items are sorted by sales rank.

  • +reviewrank
    Items are sorted by customer ratings.

  • lite
    Only essential product information is returned.

  • heavy
    All available product information is returned.

Page Number

Determine which page to jump to on your search results. If Page Number is empty, the search will return the first page of results.

From the values above we have all the information we need to put together the XML links for the 3 pages in Destination-USA:

Browse Page[Your Associates ID]&dev-t=[Your developer token]&BrowseNodeSearch=[BrowseNode]&mode=books&sort=[sort type]&offer=All&type=lite&page=[page number]&f=xml

Product Page[Your Associates ID]&dev-t=[Your developer token]&AsinSearch=[ASIN]&mode=books&sort=+pmrank&offer=All&type=heavy&page=1&f=xml

Search Results Page - Keyword Search (using the search box)[Your Associates ID]&dev-t=[Your developer token]&KeywordSearch=[keyword]&mode=books&sort=+pmrank&offer=All&type=lite&page=[page number]&f=xml

Search Results Page - Author Search (when clicking on an author in the Product Page)[Your Associates ID]&dev-t=[Your developer token]&AuthorSearch=[author]&mode=books&sort=+pmrank&offer=All&type=lite&page=[page number]&f=xml

Study how the XML feed is built for the pages. The Browse Page will have up to 3 variable attributes (BrowseNode, Sort, Page Number), while the Product Page will have only 1 variable attribute (ASIN). The Search Results Page will have 3 variable attributes (Search Type, Search Term, Page Number). The variable attributes can be passed to the pages via querystrings.

XML Scratch Pad

When you're ready to build new XML links for your own site, utilize Amazon's XML Scratch Pad. We've but scratched the surface here, there are many other options to explore - more sorting options, different modes for other product categories, etc. Once you play with the XML Scratch Pad and experiment with different searches, you'll discover the true flexibility of AWS. I can't recommend it enough, the XML Scratch Pad is your friend!