Saturday, March 12, 2011

Introduction to Google API

       Most of the current webmaster tools are created using the powerful Google API. These includes the keyword position checker, link populartiy and indexed pages checker.

In this section, we will discuss how can we use the Google API to create a tool that allows the user to check how many pages are indexed from his / her site.

How to get started?

To start writing programs using Google SOAP Search API:

1. Read their online TOS.
2. Download the Developer's kit.
3. Create a Google account to obtain a license key.

A working example- Number of pages indexed

In this example, we will be using the NuSOAP provided by NuSphere and Dietrich Ayala. NuSOAP is a toolkit that allow developers to create and consume web services based on SOAP.

A demo of this script can be found at the Google API Demo page. In addition, the working script is also available for download and free usage.

// include the NuSOAP class
if(isset($_POST['submit'])) { // buton pressed
 $parameters = array(
   'key'=> 'Your_Google_API_Key',
   'q'=> $mq,
   'start'=> '0',
   'filter'=> 'false',
 $soapclient=new soapclient('','wsdl');
 $results = $soapclient->call('doGoogleSearch',$parameters); 

The example begins with the inclusion of the NuSOAP class for later usage to interact with the Google API. We placed the lib folder on the same level of the executing script.
Upon the pressing of the button, it will grab the domain URL keyed in by the user from a form and saved it together with the site: operator in the variable, $mq.

The parameters array stores the query details for later request. Please refer to the Google reference for more information on these parameters. The example then create a new instance that refers to the Google WSDL.

Finally, the results (number of pages indexed) are saved in the $no_pages variable.

refer: useseodotcom
Introduction to Google APISocialTwist Tell-a-Friend

No comments:

Post a Comment