Unless there is no official Picasa PHP-API and most of the current how-to’s at Google (Picasa owner) itself are related to Java, I will introduce a short introduction into accessing Google Picasa API via PHP. I made up a php-class for this purpose, that is downloadable and free to use. This class is useful for accessing Picasas API and loading public Photosets and Photos. At the moment it is not able to upload photos using the API. If there is enough demand I will integrate Authorization and Uploads.
Picasa uses atom feed as API access. That include the use of XML-namespaces.
To access a users (public) albums you need an API Request like this:
Access to a users (public) photos is granted by
To get the photos of a certain photoset API call looks like:
For evaluating the XML sent by Picasa API php’s built in simplexml parser seems to be a proper way:
$feedXml = file_get_contents("http://picasaweb.google.de/data/feed/api/user/cssguru/album/Food?kind=photo"); $feed = simplexml_load_string($feedXml);
Accessing the title e.g. is simple as usual:
More kind of a problem is the data hidden in namespaced XML.
As an example here is the code for accessing the EXIF data provided by Picasa for a certain photo:
$exif=$feed->children('http://schemas.google.com/photos/exif/2007'); (int) $timeStamp = $exif->tags->time; // $timestamp gets the exif timestamp set by the camera
“http://schemas.google.com/photos/exif/2007″ is the actual namespace for exif data. Due to the fact that google changes the namespace once in a while it is essential keep it valid.
There are different namespaces in use so while accessing all data provided by Picasa you have to keep them all up to date.
A working class is attached to this small tutorial. It is capable of extracting almost all Data that is provided by Google Picasa API. Feel free to download and use it. The Class was made under influence of: http://www.dotmagic.de/blog/2007/07/16/google-picasa-api-mit-php/