- Making a Remote Request to the Google API
- Creating a Google API JavaScript Object
- Searching the Google Blog Search Service Using Ajax
- Parsing the JSON Response
- Rendering the Results as HTML
- Additional Resources
Creating a Google API JavaScript Object
Using PHP to access the Google Blog Search service allows us to create a local JSON result set that is accessible to JavaScript via Ajax. To start parsing the results, we’ll need to download the jsonparser from http://www.json.org. Once you have the jsonparser, create a JavaScript object called GoogleAPI (see Listing 2) and include the jsonparser file at the top of the file using the document.write function in order to keep the JavaScript self-contained. This GoogleAPI object will handle most of the functionality, making all the Ajax requests, parsing the JSON, and rendering the HTML elements in the web page.