Home / Articles / Create a Custom YouTube Widget Using the Google Search API

Create a Custom YouTube Widget Using the Google Search API

Article Description

The widgets provided by Google are a great way to get the functionality you’re looking for without writing any code, but sometimes there’s a need for a little more control and flexibility with layout and design. Kris Hadlock explains the steps that are necessary to use the RESTful interface provided through the Google Ajax Search API in order to create a custom JavaScript Google video widget.
Creating a Google API JavaScript Object

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.

3. Searching the Google Video Search Service Using Ajax | Next Section Previous Section