Picasa API and PHP
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:
http://picasaweb.google.de/data/feed/api/user/cssguru?kind=album
Access to a users (public) photos is granted by
http://picasaweb.google.de/data/feed/api/user/cssguru?kind=photo
To get the photos of a certain photoset API call looks like:
http://picasaweb.google.de/data/feed/api/user/cssguru/album/Food?kind=photo
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:
$valArr['titel']=(string) $feed->title;
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/


Slowene
Gibt es eine moglichkeit die heruntergeladenen xml daten mit hilfe des PHP als eine galerie mit thumbnails zu zeigen auf seiner eigener seite, das ware sehr nutzlich glaub ich?
entschuldigung fur mein schlechtes deutsch
DaveG
http://solidgone.org/Thanks for this script. It’s about the only thing that helped me access the Picasa API.
I’m trying to get hold of the album name, so I added:
$feed_arr[’gphoto’][$i][’name’] = (string)$ns_gphoto->name;
But this seems to return an empty string, despite being able to view ‘name’ when doing an print_r($gphoto).
Any idea what I’m doing wrong?