
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 Google's Web 
service, and gets back a PNG image of the book's cover. 
	- uses Google's AJAX Search API for retrieveing multimedia


This directory contains:

  * SearchGoogle.java
	- does the search 

  * WebUtils.java
	- useful support methods 
 
  * json.jar
       - this is a JAR version of the org.json library
       - from http://www.json.org/java/


There are 2 batch files:

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

  - both batch files assume that json.jar is in the local directory


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

Google's AJAX Search API
  http://code.google.com/apis/ajaxsearch/

Documentation
  http://code.google.com/apis/ajaxsearch/documentation/

Java and other Non-Javascript Environments:
      http://code.google.com/apis/ajaxsearch/documentation/reference.html#_intro_fonje
 - includes Code Snippets


Examples of using Google's AJAX Search API in Java:
    http://www.ajaxlines.com/ajax/stuff/article/using_google_is_ajax_search_api_with_java.php

    http://code.google.com/apis/ajaxsearch/documentation/#fonje


----------------------------
json.jar Installation
http://www.json.org/java/

Download the zipped file containing all the source code 
  http://www.json.org/java/json.zip

Unzip, compile, and create a JAR called json.jar:

 - unzip in local directory, creating org\ folder
 - cd org\json
 - javac *.java
 - cd ..\..			// back to local directory
 - jar cvf json.jar org		// creates json.jar

 - you can delete the zip file and the org\ folder
 
----------------------------
Compilation:

  > compile *.java

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

  > run SearchGoogle <book title>
e.g.

  > run SearchGoogle "killer game programming in java"


It will download a book cover, and create a JSON file called temp.json

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