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

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

问题描述

我正在使用 Zend_Gdata_Photos PHP 客户端访问 Google Picasa API,尝试做一些非常简单的事情,列出所有相册,然后列出每个相册中的所有照片.这是我的代码:

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

我做错了什么?

推荐答案

好吧,我从来没有想出如何做我想做的事,但找到了另一种做同样事情的方法:

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天全站免登陆