PhpRiot
Follow phpriot on Twitter
Sponsored Link
Download Article
Download this article in PDF format with all listings and files.

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

More information
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

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