
Chapter 33. Using Web Service APIs

From the website:

  Killer Game Programming in Java
  http://fivedots.coe.psu.ac.th/~ad/jg

  Dr. Andrew Davison
  Dept. of Computer Engineering
  Prince of Songkla University
  Hat yai, Songkhla 90112, Thailand
  E-mail: ad@fivedots.coe.psu.ac.th


If you use this code, please mention my name, and include a link
to the website.

Thanks,
  Andrew

============================

An application which sends a book title to Amazon's Web 
service, and gets back a PNG image of the book's cover. 
	- uses Amazon's Product Advertising API


This directory contains:

  * SignSearchAmazon.java
	- does the search 
        - you MUST MODIFY the KEY_ID and SECRET_KEY lines
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	- use the keys assigned to you by Amazon (see "Getting Keys" below)

  * WebUtils.java
	- useful support methods 

  * NamespaceContextImpl.java
	- for XML namespace contexts (by Deepak Vohra)

  * SignedRequestsHelper.java
	- for digitally signing URL queries sent to Amazon
	  (from the Product Advertising API Programming Guide)
 
  * commons-codec-1.3.jar
       - required by SignedRequestsHelper.java
       - from http://commons.apache.org/codec/   (details below)


There are 2 batch files:

  * compile.bat
  * run.bat
     - you MUST MODIFY its proxy settings to suit you
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  - both batch files assume that commons-codec-1.3.jar is in the local directory

----------------------------
Getting Keys

Go to the developer guide at 
http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/ 

Go to the "Programming Guide >> Getting Set Up" subsection which explains how you must 
first register as an Amazon Associate, and then obtain an access Key ID (sometimes 
called a AWS Access Key ID) and a secret key. 

----------------------------
API Information

Product Advertising API developer guide:
      http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/

----------------------------
commons-codec-1.3.jar Installation
http://commons.apache.org/codec/

Download the Windows binary version of Codec v1.3 (commons-codec-1.3.zip), 
unzip it, and store the JAR file in the local directory.
 
----------------------------
Compilation:

  > compile *.java

----------------------------
Execution:

  > run SignSearchAmazon <book title>
e.g.

  > run SignSearchAmazon "killer game programming in java"


It will download a book cover, and create a XML file called temp.xml

---------
Last updated: 1st July 2009
