Failed to get album list.

I want to get the list of albums from my Google Picasa account. I tried this guide. The problem is that it successfully authenticates, but does not return the album (see My code below). I can still publish a new album.

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import com.google.gdata.client.photos.PicasawebService;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.data.photos.AlbumEntry;
import com.google.gdata.data.photos.UserFeed;
import com.google.gdata.util.AuthenticationException;
import com.google.gdata.util.ServiceException;

public class Test {
    public static void main(String[] args) {
        String username = "myusername";
        String password = "mypassword";
        PicasawebService service = new PicasawebService("myapp");
        try {
            // Get list of albums. (AUTHENTICATION SUCCESSFUL BUT NO ALBUM RETURNED)
            service.setUserCredentials(username, password);
            URL url = new URL("https://picasaweb.google.com/data/feed/api/user/" + username + "?kind=album");
            UserFeed feed = service.getFeed(url, UserFeed.class);           
            List<AlbumEntry> albums = feed.getAlbumEntries();
            System.out.println(albums.size());

            // Create an album. (SUCCESSFUL, I CAN SEE IT IN MY PICASA)
            URL postUrl = new URL("https://picasaweb.google.com/data/feed/api/user/" + username);
            AlbumEntry myAlbum = new AlbumEntry();
            myAlbum.setTitle(new PlainTextConstruct("Trip to France"));
            myAlbum.setDescription(new PlainTextConstruct("My recent trip to France was delightful!"));
            AlbumEntry insertedEntry = service.insert(postUrl, myAlbum);
            System.out.println(insertedEntry.getName());
        } catch (AuthenticationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ServiceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }       
    }
}

This is the console output:

0
TripToFrance03
+3
source share
1 answer

You probably miss gdata-photos-meta-2.0.jarthe way to the classes. The code will compile and run without this jar, but getAlbumEntries()will return nothing.

+5
source

All Articles