[英]Zend_Gdata_Photos listing all albums and photos
我正在使用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-> getAlbumFeed(...)行中获得此异常:
Zend_Gdata_App_Exception: No root element
那是我做错了什么?
好吧,我从来没有想过如何做自己想做的事,而是找到了做同一件事的另一种方法:
$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) {
// ...
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.