0

我试图在新创建的相册中插入照片。但我找不到如何获取最后生成的专辑 ID 的方法。

$entry = new Zend_Gdata_Photos_AlbumEntry();
$entry->setTitle($gp->newTitle("Test album"));
$entry->setSummary($gp->newSummary("This is an album."));

$createdEntry = $gp->insertAlbumEntry($entry);

从 gdata 上的示例:

$username = "default";
$filename = "C:/xampp/htdocs/test.jpg";
$photoName = "My Test Photo";
$albumId = "5626728515640093041";
:
:

// We use the AlbumQuery class to generate the URL for the album
$albumQuery = $gp->newAlbumQuery();

$albumQuery->setUser($username);
$albumQuery->setAlbumId($albumId);

$insertedEntry = $gp->insertPhotoEntry($photoEntry, $albumQuery->getQueryUrl()); 

如果不手动输入,我如何知道最后插入的专辑?

非常感谢!

4

2 回答 2

0
/* Use the AlbumQuery class to generate the URL for the album */

$albumQuery = $gp->newAlbumQuery();
$albumQuery->setUser($user);
$albumQuery->setAlbumName($albumName);

/* Insert the photo, and the server returns the entry representing the photo after it is uploaded */

$insertedEntry = $gp->insertPhotoEntry($photoEntry, $albumQuery->getQueryUrl());
$pialbum = $insertedEntry->getGphotoAlbumId()->getText();
$pifoto =  $insertedEntry->getGphotoId()->getText();
于 2011-07-19T20:02:23.503 回答
0

看看http://code.google.com/intl/zh-TW/apis/picasaweb/docs/2.0/developers_guide_protocol.html#AddAlbums

Picasa 网络相册使用您发送的数据创建一个新相册,然后返回 HTTP 201 状态代码,以及以“条目”元素形式的新相册副本。返回的条目与您发送的条目相似,但返回的条目包含服务器添加的各种元素,例如“id”元素。

因此,您可以通过解析返回的条目来获取专辑ID。

于 2011-07-09T08:57:48.683 回答