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
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.
