[ Team LiB ] Previous Section Next Section

Recipe 27.1 Getting Set Up with Google's Web API

Problem

You want to use Google's Web API to make Java-enabled searches of Google's vast web index.

Solution

Download the Google Web APIs SDK. Create a Google account and get a license key that allows the use of Google's Web API.

Discussion

The Google Web APIs SDK includes an archive named google.jar. This file contains the classes that your program will use to connect with Google during searches. Here are the specific steps you take to prepare the web application for connecting with Google:

  1. Download the zipped SDK from http://www.google.com/apis/download.html. Unpack this file into a directory (named googleapi in Beta Version 3.0 of the Google Web APIs). This directory contains google.jar, along with a lot of code samples and documentation.

  2. Create a Google account and get a license key, which is encoded text that looks like "5W1ABCyzPSyI3rIa5Pt3DtXMatsdzaSGB." Your Java code uses this key when it queries Google's index. The query will fail if it is not accompanied by a valid key.

  3. Place the google.jar file in the WEB-INF/lib directory of the web application.

  4. Develop your Java classes for connecting with Google, using the com.google.soap.search package from the google.jar file.

See Also

The home for the Google Web APIs: http://www.google.com/apis/; the Google web APIs SDK: http://www.google.com/apis/download.html.

    [ Team LiB ] Previous Section Next Section