Zend_Gdata
Zend Framework gives you the possibility to interact with Gdata services, which are provided by most of the Goolge services. You can find more on the docs page of Zend_Gdata. The basic principle is that you can connect a service with you API key, given by Google. What I’m about to show you is how do connect such a service.
In theory Zend_Gdata depends on Zend_Http_Client and you’ve to connect it with an instance of this class.
// 1. setup API key $apiKey = 'your_api_key_here'; // 2. retrieve videos via GData Atom $client = new Zend_Http_Client(); $gdata = new Zend_Gdata_YouTube(null, 'my-app', null, $apiKey); |
Note that you’ve to replace your API key in the chunk above.
Now once that you’ve connected the YouTube service you can iterate through the entries from the video feed.
$videoFeed = $gdata->getUserUploads('username'); foreach ($videoFeed as $entry) { echo $entry->getTitle(); } |
The thing is that you can modify a bit the code above. As ZF docs says if you don’t setup a Zend_Http_Client a default with default configuration, so you can omit this and simple write:
// 1. setup API key $apiKey = 'your_api_key_here'; // 2. retrieve videos via GData Atom $gdata = new Zend_Gdata_YouTube(null, 'my-app', null, $apiKey); |