NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > Webmaster Tutorials
Reload this Page How to use Google API - Number of indexed pages

Webmaster Tutorials Instructional webmaster-related how-to's and tutorials.

Advanced Search
0 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 11-09-2006, 06:35 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
AbsoluteKC's Avatar
Join Date: Apr 2006
Posts: 980
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 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.
????: NamePros.com http://www.namepros.com/webmaster-tutorials/256291-how-use-google-api-number-indexed.html

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/NewA....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']);  
????: NamePros.com http://www.namepros.com/showthread.php?t=256291
  
  
$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/soapsear...rence.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/soapsear...rence.html#3_1

Hope it helps
AbsoluteKC is offline  
Old 02-17-2007, 04:16 PM   #2 (permalink)
Account Suspended
Join Date: Sep 2006
Posts: 1,059
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  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 12:59 AM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger