views:

51

answers:

1

I'm using the Zend_Gdata_Photos PHP client to access the Google Picasa API, trying to just do something very simple, list all the albums, and then list all the photos within each album. This is my code:

$client = Zend_Gdata_ClientLogin::getHttpClient('*****', '*****', Zend_Gdata_Photos::AUTH_SERVICE_NAME);
$gp = new Zend_Gdata_Photos($client);

$userFeed = $gp->getUserFeed('default');
foreach ($userFeed as $albumEntry) {
 echo "<h2>{$albumEntry->title->text} ({$albumEntry->id->text})</h2>";
 $albumFeed = $gp->getAlbumFeed($albumEntry->id->text);
 foreach ($albumFeed as $photoEntry) {
  echo "{$photoEntry->title->text}<br>";
 }
}

When that runs I get this exception from the $gp->getAlbumFeed(...) line:

Zend_Gdata_App_Exception: No root  element

And idea's what I'm doing wrong?

A: 

Well, I never figured out how to do what I wanted, but found an alternative way of doing the same thing:

$query = new Zend_Gdata_Photos_UserQuery();
$userFeed = $gp->getUserFeed(null, $query);
foreach ($userFeed as $albumEntry) {
    $query = new Zend_Gdata_Photos_AlbumQuery();
    $query->setAlbumId($albumEntry->gphotoId->text);
    $albumFeed = $gp->getAlbumFeed($query);
    foreach ($albumFeed as $photoEntry) {
        // ...
    }
}
Jack Sleight