AlbumID is one important property of Picasa web album. Each web album has a AlbumID which is used to identify Album. When we are externally accessing the web album we need to pass on AlbumID to identify which album we want to access. In this post we will learn how we can pull AlbumID for each of the web album stored in our Picasa web account.
In my last post we navigated to Picasa web album and clicked on RSS link to fetch AlbumID. We can pull the AlbumID with the help of Google Data API. To start with I have designed following GUI interface in .NET. I have a list view and button control. When user will click on "Get Album List"; the album details including AlbumID will be pulled from Picasa. The album details will be shown in our list view.
I am importing following Google Data API namespaces in the form.
using Google.GData.Client; using Google.GData.Photos; using Google.GData.Extensions; using Google.GData.Extensions.Location; using Google.Picasa;
The .NET code snippet on the Get Album List button is following:
private void button1_Click(object sender, EventArgs e) { //Adding columns in listview control listView1.Columns.Add("Album ID"); listView1.Columns.Add("Album Title"); listView1.Columns.Add("No Of Photo"); PicasaService myPicasa = new PicasaService("Vikash-Test-Picasa"); myPicasa.setUserCredentials("abc@gmail.com", "abcpassword"); AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("abc")); PicasaFeed myPicasaFeed=myPicasa.Query(myAlbumQuery); foreach (PicasaEntry p in myPicasaFeed.Entries) { AlbumAccessor myAlbum = new AlbumAccessor(p); listView1.Items.Add((new ListViewItem(new string[] { myAlbum.Id.ToString(),myAlbum.AlbumTitle.ToString(), myAlbum.NumPhotos.ToString()}))); } }
As you can see from the code we are creating the AlbumQuery and passing it to PicasFeed class. We are reading the Album ID, Album title and No of Photo stored in each Picasa web album.
After setting up the code, I run the form and clicked on "Get Album List" button. The code runs successfully and pulled the Album ID, Album title and No of Photo stored in each Picasa web album.
So we can pull the AlbumID of each album programmatically with Google Data API.
Thanks for reading till this point.
If you want to explore more with the Source code of this post; please visit Download Zone.