Create Your Own Search Engine with PHP and Google Web Services - Interacting with Google's Web Services
(Page 2 of 4 )
Google has made only three methods available in their Web API. You will see soon that it’s just more than enough to build powerful applications.
Here is what they look like:
doGoogleSearch() – search for specified term in the Google database.
doGetCachedPage() – retrieve a page cache from the Google cache.
doSpellingSuggestion() – retrieve a spelling suggestion from Google.
The above methods exposed by the Google’s Web Services make it possible to use number of very cool features – Web search, cached document retrieval, phrase correction – in a simple but extensible manner, which opens up very interesting new possibilities for Web developers. Pic. 1 shows how a client program invokes a method from Google’s Web Services. Let’s rock and roll.
Pic. 1: Exchanging SOAP packets between the client and Google Web ServicesThe skeleton of our client code (pseudo codes) will look something like following (Pic. 2):
<?php
if (!$_POST[‘query’])
{
//display form
}
else
{
//execute query on Google
} Pic. 2: Code Skeleton As you can see, the script is split into two sections, one for the search form and the other for the search result. An "if" statement is used to decide which section of the script to execute.
Next: Walkthrough Example >>
More PHP Articles
More By Ahm Asaduzzaman