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

Related Books
Restful Web Services

Restful Web Services

"Every developer working with the Web needs to read this book." -- David Heinemeier Hansson,...

Professional Web APIs with PHP: eBay, Google, Paypal, Amazon, FedEx plus Web Feeds

Professional Web APIs with PHP: eBay, Google, Paypal, Amazon, FedEx plus Web Feeds

Offers hands-on tips and numerous code examples that show Web developers how to leverage...

Searching Google With The Google API

Introduction

This article covers performing search queries on Google using their API. This means you can transparently run a Google search in the background, and then present the results to your users however you want to.

The Google API is a SOAP web service. SOAP (Simple Object Access Protocol) is an XML schema used for calling a remote procedures (usually) over the web. In this case, the remote procedure is Google search.

To achieve this, there are a few things we firstly need:

  1. A Google license key – This is your own key for access the Google web service. To get your key, visit the Google APIs page and create an account.
  2. NuSOAP – This is a SOAP toolkit for PHP. Using this saves us all the hassle of dealing directly with SOAP web services. Download from SourceForge.

In this article, we are going to create a single PHP script called google.php, to simply demonstrate how to query Google. Hopefully using this information, you will be able to come up with more advanced ways of using the API.

The Google API does offer querying of their cache, as well as spelling requests, however, this article covers only performing searches. If you’re interested in these other types of queries, you’re best of reading the API reference guide.

In This Article