PhpRiot
Download This Article
Download this article in PDF format with all listings and files.

Price: $5.00 AUD
(Approx. $4.10 USD)

More information
Browse Articles
Ajax (4), APC (1), CAPTCHA (1), CSS (3), Debugging (1), File Upload (1), Google (3), Google Maps (2), JavaScript (12), JSON (2), MVC (1), MySQL (7), onbeforeunload (1), OOP (1), PHP (28), PhpDoc (1), PostgreSQL (6), Prototype (11), Reflection (1), RFC 1867 (1), Robots (1), Scriptaculous (1), SEO (1), Sessions (1), SimpleXML (1), Smarty (5), SOAP (1), SPL (1), Templates (2), W3C (1), XHTML (1), Zend Framework (1), Zend_Search_Lucene (1)

PhpRiot Newsletter
Your Email Address:

Searching Google With The Google API

Executing The Soap Procedure Call

Now that we have our parameters, we can call the SOAP web service. To do this we are using the NuSOAP library.

Listing 2 listing-2.php
<?php
    require_once('nusoap.php');
 
    $soap = new SoapClient('http://api.google.com/GoogleSearch.wsdl', 'wsdl');
    $result = $soap->call('doGoogleSearch', $parameters);
?>

Now to explain this:

  • The URL of the Google web service is at http://api.google.com/GoogleSearch.wsdl
  • WSDL stands for Web Service Description Language. The WSDL provides a description of how the service works, what procedures it has available, and the parameters required for calling those procedurs. If you visit that URL in your browser, you will a see an XML file description everything about the web service.
  • The procedure we’re calling is called doGoogleSearch

So once you run the call() function of NuSOAP, the actual request is performed, meaning that Google is now queried for that search term.

The last thing to do now is to handle the results.

In This Article


Tagged in , ,