我正在使用Zend_Gdata_Photos PHP客户端访问Google Picasa API,尝试做一些非常简单的事情,列出所有相册,然后列出每张专辑中的所有照片。这是我的代码:
$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>";
}
}
当它运行时,我从$ gp-&gt; getAlbumFeed(...)行获得此异常:
Zend_Gdata_App_Exception: No root element
想法是我做错了什么?
答案 0 :(得分:0)
好吧,我从来没有想过如何做我想做的事情,但找到了做同样事情的另一种方式:
$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) {
// ...
}
}