Zend_Gdata_Photos listing all albums and photos

谁都会走 提交于 2020-01-06 04:54:09

问题


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?


回答1:


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) {
        // ...
    }
}


来源:https://stackoverflow.com/questions/3424762/zend-gdata-photos-listing-all-albums-and-photos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!