2

I am having trouble accessing Picasa web albums by album name. I have album name 'My Test Album'. If I use that name (including the spaces) I receive the error:

Fatal error: Uncaught exception 'Zend_Uri_Exception' with message 'Invalid URI supplied'

Without the spaces 'MyTestAlbum' works fine:

// Construct the query                      
$query = $this->photos->newAlbumQuery();
$query->setUser( "default" );
$query->setAlbumName( "MyTestAlbum" ); //This works fine

This causes error:

// Construct the query                      
$query = $this->photos->newAlbumQuery();
$query->setUser( "default" );
$query->setAlbumName( "My Test Album" ); // This causes error

My question is that what characters are not allowed so I can strip them out before calling setAlbumName()?

Or any suggestions on a better approach?

Thanks Ian

Toretto
  • 4,721
  • 5
  • 27
  • 46
nakunakifi
  • 73
  • 3

1 Answers1

0

You can only get a list of albums that match a specific name:

// Find the album for the given accountId.
$albumQuery = $picasa->newAlbumQuery();
$albumQuery->setUser( $user );
$albumQuery->setAlbumName( "AlbumName" ); // No spaces.
$albumQuery->setMaxResults( 1 );

$albumId = null;

try {
  $albumFeed = $picasa->getAlbumFeed( $albumQuery );

  foreach( $albumFeed as $key => $entry ) {
    $albumId = $entry->getGphotoAlbumId();
  }
}
catch( Zend_Gdata_App_Exception $ex ) {
  // Create the album because the album name could not be found.
  $albumId = $this->createAlbum( $picasa, "AlbumName" );
}

At this point, $albumId should be referencing a valid album.

The code iterates over an album feed. You will have to ensure that the album name is uniquely identified; otherwise the code will return multiple albums that match the names.

Note that if you delete an album, then recreate an album of the same name, there is a bug that prevents you from retrieving that album. See also: List recreated album names that were previously deleted.

Community
  • 1
  • 1
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315