Searching Google With The Google API


This article covers performing search queries on Google using their API. This means you can transparently run a Google search in the background, and then present the results to your users however you want to.

The Google API is a SOAP web service. SOAP (Simple Object Access Protocol) is an XML schema used for calling a remote procedures (usually) over the web. In this case, the remote procedure is Google search.

To achieve this, there are a few things we firstly need:

  1. A Google license key – This is your own key for access the Google web service. To get your key, visit the Google APIs pageand create an account.
  2. NuSOAP – This is a SOAP toolkit for PHP. Using this saves us all the hassle of dealing directly with SOAP web services.Download from SourceForge.

In this article, we are going to create a single PHP script called google.php, to simply demonstrate how to query Google. Hopefully using this information, you will be able to come up with more advanced ways of using the API.

The Google API does offer querying of their cache, as well as spelling requests, however, this article covers only performing searches. If you’re interested in these other types of queries, you’re best of reading the API reference guide.

Leave a Reply

Your email address will not be published. Required fields are marked *