Background
I would like to list all the albums for my account matching the specified name.
Problem
After deleting the album and then re-creating the album with the same name, the code for $albumQuery->setAlbumName( ... ) to find the name of the album failed with 404, although the album was successfully created.
The following code works fine:
// 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 );
This line, which exists immediately after calling setMaxResults , is not executed:
$albumFeed = $picasa->getAlbumFeed( $albumQuery );
When executing the above line, the following error occurs:
Exception: expected response code 200, received 404
Update # 1
The following code works, but not sequentially:
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"; }
Performs as expected until the album is deleted. When you recreate an album that has been deleted, it seems that the API cannot find the recreated name. As a result, the above code creates new albums with the same name, which is undesirable.
Update # 2
This seems like a mistake; I registered a problem:
https://code.google.com/p/gdata-issues/issues/detail?id=4516
Question
How do I get the album ID using the Picasa API for an album that has been deleted and then recreated?