Zend_Gdata_Photos列出所有相册和照片 [英] Zend_Gdata_Photos listing all albums and photos

查看:196
本文介绍了Zend_Gdata_Photos列出所有相册和照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的PHP Zend_Gdata_Photos客户端访问谷歌的Picasa API,试图只是做东西很简单,列出所有的专辑,并列出每一张专辑中的照片。这是我的code:

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>";
 }
}

在运行我从$ GP-> getAlbumFeed(...)行此异常:

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?

推荐答案

好了,我从来没有想出如何做我想要的东西,但发现做同样的事情的另一种方式:

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

这篇关于Zend_Gdata_Photos列出所有相册和照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆