【问题标题】:Zend_Gdata_Photos listing all albums and photosZend_Gdata_Photos 列出所有相册和照片
【发布时间】:2011-03-26 09:11:34
【问题描述】:

我正在使用 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

想法是我做错了什么?

【问题讨论】:

    标签: php api zend-framework gdata picasa


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-21
      • 1970-01-01
      相关资源
      最近更新 更多