[advanced search]
NamePros Domain Auction
Live Event This Thursday at 6PM EST - Prebidding open now
16 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Today's Posts Domain Services
Go Back   NamePros.Com > Design and Development > Webmaster Tutorials
User Name
Password

Closed Thread
 
Thread Tools
Old 11-09-2006, 07:35 PM   · #1
AbsoluteKC
NamePros Regular
 
AbsoluteKC's Avatar
 
Trader Rating: (12)
Join Date: Apr 2006
Posts: 696
NP$: 60.55 (Donate)
AbsoluteKC is a splendid one to beholdAbsoluteKC is a splendid one to beholdAbsoluteKC is a splendid one to beholdAbsoluteKC is a splendid one to beholdAbsoluteKC is a splendid one to beholdAbsoluteKC is a splendid one to behold
How to use Google API - Number of indexed pages

I hope that this guide will help the new API developers in gaining a better understanding of the Google API so as to develop their own applications.

Stuff you need before coding

1. This guide uses NuSOAP class as the interaction with the Google web services. You can download the class at:
http://sourceforge.net/projects/nusoap/

2. A Google API license key is required. You can apply it here:
https://www.google.com/accounts/New...e.com/createkey

3. This guide is short and coded in PHP to ensure an easier understanding.

Live Demo

A live demo can be found at:
http://www.useseo.com/google-api-demo.php

The script is also available for download. Simply change the Google key so that the script can work.

Coding
The following codes are the essential part of the script once the form button is pressed:
PHP Code:
<?php
require_once('lib/nusoap.php'); // include the nusoap class

if(isset($_POST['submit'])) { // upon button pressed
     
  //trim the user's url
  
$qurl=trim($_POST['url']);  
  
  
$mq='site:'.$qurl;
   
   
$parameters = array(
    
'key'=> 'Your_Google_API_Key',
    
'q'=> $mq,
    
'start'=> '0',
    
'maxResults'=>'10',
    
'filter'=> 'false',
    
'restrict'=>'',
    
'safeSearch'=>'false',
    
'lr'=>'',
    
'ie'=>'',
    
'oe'=>''
    
);
    
    
//Create a new soap client, feeding it googlesearch.wsdl
    
$soapclient=new soapclient('http://api.google.com/GoogleSearch.wsdl','wsdl');
    
    
//save the results into $results array
    
$results = $soapclient->call('doGoogleSearch',$parameters);   
    
    
//save the total number of pages indexed
    
$no_pages=$results['estimatedTotalResultsCount'];    
}
?>


Code explanation
The first line includes the NuSOAP class for later usage.
The url keyed in by the user was appended with the site: operator on the left and saved in the parameter array.

Further details of the parameters can be found at: http://code.google.com/apis/soapsea...erence.html#2_1

Finally, the results are saved in the $no_pages variable for display.

Other possible usage
As we only used the estimatedTotalResultsCount element here, there are many other elements that you can make use of to develop other applications. The format of the search response from Google can be found at:
http://code.google.com/apis/soapsea...erence.html#3_1

Hope it helps


Please register or log-in into NamePros to hide ads
__________________
AbsoluteKC is offline   Reply With Quote
Old 02-17-2007, 05:16 PM   · #2
YesBrilliant
Account Closed
 
Trader Rating: (21)
Join Date: Sep 2006
Posts: 1,075
NP$: 0.00 (Donate)
YesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to all
Nice tutorial.

It realy helped.

Thanks for sharing!
YesBrilliant is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Skilled Graphics http://www.domainate.com/y/ http://www.domainate.com/y/
Advertise your business at NamePros
All times are GMT -7. The time now is 02:27 AM.


Powered by: vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0