Search code examples
c#.netgdata-apipicasa

How to get a single photo by ID from Picasa using the google-gdata .net API


I'm trying to use the .net API library to get a single image by ID from Picasa.

So far, I've tried to find the correct call by doing:

  • new Photo(); but there are no constructor params to tell it which photo to get
  • new Entry(); same as above
  • PicasaQuery.CreatePicasaUri; but I have to specify the albumId as well then, which I don't have.

I also can't seem to find the REST call for this in the API documentation (with which I could circumvent the .net API completely).

I've of course Googled this, but either nobody seems to want to get a single image by ID or I am missing the obvious (or this is a crazy scenario...).


Solution

  • The CreatePicasaUri method has three variations, one of which accepts a photo ID. You're right that you'll need the album ID but you should be able to obtain that.

    To get a list of albums and their associated info (note that I use a structure called MyAlbum to store all of the photo info from the album for use later in my code):

            Dim username As String = "default"
            Dim query As AlbumQuery = New AlbumQuery(PicasaQuery.CreatePicasaUri(username))
    
            Dim feed As PicasaFeed = service.Query(query)
            Dim albums As New List(Of MyAlbum)
    
            For Each entry As PicasaEntry In feed.Entries
    
                Dim ac As AlbumAccessor = New AlbumAccessor(entry)
                Dim a As MyAlbum
                a.Name = ac.AlbumTitle
                a.ImageCount = ac.NumPhotos
                a.ID = ac.Id
                albums.Add(a)
    
            Next
    

    To query based on Photo ID:

    Dim query As PhotoQuery = Nothing
    query = New PhotoQuery(PicasaQuery.CreatePicasaUri(username, albumID, photoID))