2011-07-07 68 views
0

我試圖在新創建的相冊上插入照片。但我無法找到如何獲得最後生成的相冊ID的方法。獲取Picasa(gdata)中最後創建的相冊的ID PHP

$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()); 

我怎樣才能知道,而無需手動鍵入它最後插入的專輯?

非常感謝!

回答

0

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

Picasa網絡相冊來看看使用你發送的數據創建一個新的專輯,然後返回一個HTTP 201狀態碼,用的形式,新專輯的副本一起「入口「元素。返回的條目類似於您發送的條目,但返回的條目包含由服務器添加的各種元素,例如「id」元素。

因此,您可以通過解析返回的條目來獲取albumID。

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();