Zend_Gdata for Picasa, YouTube, Google Documents List

p. karwin_bill_frontThe Zend_Gdata component of Zend Framework offers PHP 5 classes to access services supported by the Google Data APIs. The recent Zend Framework 1.0.3 release includes new support for some great services, including “Picasa Web Albums”:http://code.google.com/apis/picasaweb/, “YouTube”:http://code.google.com/apis/youtube/, and “Google Documents List”:http://code.google.com/apis/documents/.

p. The Zend Framework project has been very fortunate that the developers at Google agreed to release their PHP 5 client for the Google Data APIs as part of Zend Framework. They get some benefit in return, because their development work is made easier by using several Zend Framework components, including Zend_Http_Client and Zend_Mime.

h2. Picasa Web Albums

p. This service has functions to retrieve a feed, or individual entries, for users, albums, and individual photos. You can also view the images, thumbnails, and comments.

p. If your application authenticates with the Google Data service, you can create albums, post photos, or create comments or tags, all from PHP 5 code.

h2. YouTube

p. The YouTube API allows you to search for public videos by keyword searches, by user who posted the video, and by standard feeds such as today’s top-rated videos. The API returns a feed, which you can use to browse through the list and even view a YouTube video in your web application.

p. You can also retrieve a feed of comments for a given video, and a feed of related videos. Also information about users, such as profiles, playlists and subscriptions. Just like your very own youtube.com! Currently the Google Data API for YouTube is read-only, and you can fetch only public data.

h2. Google Documents List

p. The Documents List API allows you to retrieve a list of your Google Documents such as word processor documents, spreadsheets, and presentations.

p. You can filter the list by document type, or in typical search-engine fashion, query for documents containing specific key words.

p. This API also allows you to upload documents from your computer, and convert them to Google Documents.

h2. Check out the Demo Code

p. Zend Framework 1.0.3 includes demo code that show how to access these services in your PHP 5 applications. In fact, the demos are pretty useful tools on their own! After you “download the complete ZF”:http://framework.zend.com/download or the “Zend_Gdata bundle”:http://framework.zend.com/download/gdata (which is simply a subset of ZF), look for these files:

* ZF/demos/Zend/Gdata/Photos.php
* ZF/demos/Zend/Gdata/Docs.php
* ZF/demos/Zend/Gdata/YouTubeVideoBrowser/index.php

You can try out these demos easily on your system:

# Configure Apache with an “Alias”:http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias to the Gdata directory
# Enable Apache with “mod_php”:http://php.net/manual/en/install.php
# Enable PHP 5.1.4 or higher with “ext/php_openssl”:http://php.net/openssl

Ryan Boyd is the lead developer on the Google Data API project at Google. I had the pleasure of working with Ryan for about a year while I was the lead on the Zend Framework project. Mostly I did code review, and answered questions about PHP coding standards in the ZF project, and got him started using PHPUnit, PHPDoc, and DocBook.

h2. More Information

Read the Zend_Gdata documentation for these components:

*(disc) “Picasa Web Albums”:http://framework.zend.com/manual/en/zend.gdata.photos.html
* “YouTube”:http://framework.zend.com/manual/en/zend.gdata.youtube.html
* “Google Documents List”:http://framework.zend.com/manual/en/zend.gdata.docs.html

Read reference documentation for the Google Data API for these services:

*(disc) “Picasa Web Albums”:http://code.google.com/apis/picasaweb/
* “YouTube”:http://code.google.com/apis/youtube/
* “Google Documents List”:http://code.google.com/apis/documents/

View the “demo video”:http://feeds.feedburner.com/~r/OfficialGoogleDataApisBlog/~3/193242322/posted-by-ryan-boyd-google-data-apis.html on Blogger, in which the Google developers talk about these services and demonstrate accessing them from PHP 5 code using Zend_Gdata.