- Making a Remote Request to the Google API
- Creating a Google API JavaScript Object
- Searching the Google Video Search Service Using Ajax
- Parsing the JSON Video Result Set
- Rendering the results as HTML
- Additional Resources
Creating a Google API JavaScript Object
Using PHP to access the Google Video 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 (Listing 2, GoogleAPI.js) 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.