Wednesday, October 8, 2008

A little experience

After reading some materials about google and google api, I wanted to try some of them by myself. It must be a very interesting experience. There are many APIs, as I mentioned before, in google code garden. At first, I want to have a look at search apis. What kind of search service does google api provide? If you browns from http://code.google.com/. You can find:
* Google Book Search APIs,
“Google Book Search is our effort to make book content more discoverable on the Web. You can easily and reliably integrate with this repository from your site, in a number of ways”
* Google Code Search Data API
“The Google Code Search data API allows client and web applications to search public source code for function definitions and sample code.”
* Google AJAX Search API,
“…lets you use JavaScript to embed a simple, dynamic Google search box and display search results in your own web pages, or use search results programmatically in innovative ways…”
* Google Custom Search API
“…enables you to search over a website or a collection of websites. You can harness the power of Google to create a search engine tailored to your needs and interests, and you can present the results in your website. Your custom search engine can prioritize or restrict search results based on websites you specify. ”

Ajax Search api is one of my interests. So I picked up this type of flower from the garden first.
1. Set up tomcat on my computer as the server. After inputting http://localhost:8080/ in the browser address box and click enter, you can see the test page of tomcat. This means the server run successfully on the computer.
2. Using “IPconfig” command in windows operation system, I checked out IP address of my computer. For example:100.100.100.100. Then input http://100.100.100.100:8080/ in the browser. This time the test page of tomcat should appear again.
3. Using the Ajax search API, you should get a Google AJAX API key. To get the key, which is free, a google account is needed. When you sign in with the account, google will ask you to provide the web site URL in which you want to integrate the search service. I think the mechanism of generating a key has some kind of relationship with the URL provided, because after the key is generated, it says: “This key is good for all URLs in this directory.” The directory is domain name you provided, something like http://www. Mybloger.com/. Since I didn’t have it, I substituted it with http://100.100.100.100:8080/. It is ok.
4. When I got the key, google also provided some code to start the experience. Those were some javascript codes, which can run on the static web pages. Copy the codes into a created html file, then save and put it into a subfolder of tomcat’s webapp folder.
5.I ran the html page on tomcat, then, a "search" page appeared on the computer finally!
What I mentioned is a basic try of the API. You can edit codes to catch your own flavor. Google’s api documentation is the best choice in this case.

2 comments:

Ning Ding said...

Tomcat is so good because it is small and easy to deploy. Maybe in the future we can exchange the experiences of building a website from the very start.

Wen Yue said...

you are welcome.
we can discuss about it together