background preloader

Accessing the Picasa API with PHP

Facebook Twitter

Picasa and PHP. I noted in my previous post that one of the difficulties I found in building my photo gallery was figuring out how to access the Picasa API using PHP.

Picasa and PHP

If you look into the Google developer pages, or do a Google search to find out how this can work, you’ll usually end up reading about something called The Zend Framework for GData (GData is Google’s generalized API protocol for their services like Picasa, Calendar, etc…). I’m not knowledgeable enough about Zend to comment on its overall value, although I’ve read very good things about it.

The point was that learning it would have taken me more time than I wanted to spend just figuring out how to do one simple thing with Picasa. So I went about learning what I needed to learn on my own. So let’s back up so I can explain why this was difficult for me in the first place. The first two parts were relatively easy, but I couldn’t find the basic information to do the HTTP request.

Here’s the code I used to get an XML feed of all of my albums: ClientLogin with PHP CURL. I find it quite hard having a comprehensive sample or documentation on using Google data services with bare PHP code.

ClientLogin with PHP CURL

Finally - with some trials and errors - can get things done and now fully understand how to interact with GData Protocol. One of the basic ways to interact with Google data services is to use ClientLogin, in which your web application or desktop application can authenticate into Google services using raw http and xml protocol. So, based on Google documentation at how to use curl, I have written some PHP codes to test against each service. One that had been fully tested is Picasa. There are several issues when I try to use ClientLogin mechanism in PHP : The application doesn't know the SSL key and if we can add it dynamically, it will be limited if you are using shared host environment.You have to construct your own HTTP header as authentication process part.

Thanks to curl library function that can overcome all the issues. Obtaining Login Token <? <? Using the service. Google ClientLogin PHP Examples. The latest version of Shashin (v2.6), which is my plugin for using Picasa with WordPress, adds support for unlisted Picasa albums.

Google ClientLogin PHP Examples

Supporting unlisted albums is possible because 1. Picasa does not actually require any authentication to view the photos in unlisted albums if you know their URLs (they simply don’t show you links to view unlisted albums at Picasa, or view their RSS feeds, unless you’ve been authorized), and 2. the Google ClientLogin API is available. The ClientLogin API documentation has really good prose, but precious little code. There is a freely available PHP library (fron Zend) for interacting with the Google APIs, but I didn’t want to bloat Shashin by several megabytes just so I could use the library’s authentication method (and there are enough interdependencies in the library that I couldn’t easily extract the authentication components).

ClientLogin Authentication Here is my ClientLogin authentication function, which can be easily re-used outside of Shashin. Picasa and PHP. Getting Started with the Google Data PHP Client Library - Google Data APIs. Warning: This page is about Google's older APIs, the Google Data APIs; it's relevant only to the APIs that are listed in the Google Data APIs directory, many of which have been replaced with newer APIs.

Getting Started with the Google Data PHP Client Library - Google Data APIs

For information about a specific new API, see the new API's documentation. For information about authorizing requests with a newer API, see Google Accounts Authentication and Authorization. Video: Watch Trevor Johns go through client library installation, library architecture, and a code walkthrough. Jochen Hartmann, Google Data APIs Team Updated October 2008 (Originally written by Daniel Holevoet) Introduction. Picasa Web Albums Data API. Picasa Web Albums allows client applications to view and update albums, photos, and comments in the form of Google Data API feeds.

Picasa Web Albums Data API

Your client application can use the Picasa Web Albums Data API to create new albums, upload photos, add comments, edit or delete existing albums, photos, and comments, and query for items that match particular criteria. Audience This document is intended for programmers who want to write client applications that can interact with Picasa Web Albums. It provides a series of examples of basic Data API interactions using raw XML/HTTP, with explanations. After reading this document, you can learn more about interacting with the API using our client libraries by reading the language-specific examples found on the other sections of this document. For Picasa Web Albums Data API reference information, see the reference guide. This document assumes that you understand the general ideas behind the Google Data APIs protocol. Creating an account Authorizing requests. Developer's Guide: PHP - Picasa Web Albums Data API.

Picasa Web Albums allows client applications to view and update albums, photos, and comments in the form of Google Data API feeds.

Developer's Guide: PHP - Picasa Web Albums Data API

Your client application can use the Picasa Web Albums Data API to create new albums, upload photos, add comments, edit or delete existing albums, photos, and comments, and query for items that match particular criteria. In addition to providing some background on the capabilities of the Picasa Web Albums Data API, this guide provides examples for interacting with the API using the PHP client library.

If you're interested in understanding more about the underlying protocol used by the PHP client library to interact with the Picasa Web Albums API, please see the protocol guide. Develop PHP applications with Picasa Web Albums. Introduction As someone who takes a lot of digital photos, I'm no stranger to disk clutter—my computer has hundreds of megabytes of old photos, most with sketchy or non-existent labels.

Develop PHP applications with Picasa Web Albums

Only a few months ago, when I finally tried out Google's free Picasa photo management software, some method began to emerge from the madness. But Picasa is more than just a tool you can download off the Web—it also exists online, as a free photo-sharing site called Picasa Web Albums.