4
背景
我想列出與我的帳戶匹配給定名稱的所有相冊。列表重新創建了以前刪除的相冊名稱
問題
刪除相冊,然後重新創建具有完全相同的名稱的專輯之後,$albumQuery->setAlbumName(...)
代碼查找專輯名稱失敗,一個404,即使已成功創建的相冊。
下面的代碼細運行:
// This is correct -- adding photographs to albums works.
$client = $this->login($user, $pass, $picasa);
$picasa = $this->newPhotographService($client);
$albumQuery = $picasa->newAlbumQuery();
$albumQuery->setUser($user);
$albumQuery->setAlbumName("17"); // This is the literal name of the album.
$albumQuery->setMaxResults(10);
這條線,該呼叫後立即存在於setMaxResults
,失敗:
$albumFeed = $picasa->getAlbumFeed($albumQuery);
在執行時發生錯誤上面的行:
異常:預期響應代碼200,得到404
更新#1
下面的代碼工作,但不能始終如一:
echo "Search for the album named $accountId for $user\n";
$albumQuery = $picasa->newAlbumQuery();
$albumQuery->setUser($user);
$albumQuery->setAlbumName("ALBUM17");
$albumQuery->setMaxResults(1);
$albumId = null;
try {
echo "\nGet album feed from albumQuery.\n";
$albumFeed = $picasa->getAlbumFeed($albumQuery);
// The feed returns a list of photos; each photo has an album ID.
foreach($albumFeed as $key => $entry) {
$albumId = $entry->getGphotoAlbumId();
}
echo "\nFound album ID: ALBUM17\n";
}
catch(Zend_Gdata_App_Exception $ex) {
echo "\nError: " . $ex->getMessage() . "\n";
echo "\nCreate album.\n";
// Create the album.
$albumId = $this->createAlbum($picasa, "ALBUM17");
echo "\nCreated album ID: ALBUM17\n";
}
預期,直到專輯被刪除此進行。重新創建已刪除的相冊時,似乎API無法找到重新創建的名稱。結果是上面的代碼創建了具有相同名稱的新相冊,這是不可取的。
更新#2
這似乎是一個錯誤;我已經登錄的問題:
https://code.google.com/p/gdata-issues/issues/detail?id=4516
問題
你如何檢索相冊ID使用Picasa的PHP API爲冊頁被刪除,然後重新創建?