In this post we will use Googe Data API i.e. GData to read information from one of popular Google service – Google Picasa Web. Picasa provides photo sharing services to it users where you can upload and share your images with the world.
First let us see what we want to read from Google Picasa web service. The below screen shot belongs to my Picasa account. I have total 6 web Albums in my Picaca account. The Goal is to read the Album titles using Google Data API. I came from .NET bacKground so I selected Ms Visual Studio 2010 and C#. I downloaded the .NET library offered by Good Data API and run the setup in my machine. This went fine except I have to download it twice as my connection broke out in between.
I fired up my Ms-Visual Studio 2010 and selected a Windows Form based Project. I added the reference of Google Data API. I am using Windows 7 in my case so my Google Data API was installed in C:\Program Files (x86)\Google\Google Data API SDK\Redist folder. After adding the reference; all Google Data API library was shown in my solution explorer
I designed a small form with one list box and and one button. The list box is where I want to display the Web Album titles.
The .NET code snippet I used on the button click event is following:
private void button1_Click(object sender, EventArgs e) { PicasaService myPicasa = new PicasaService("Vikash-Test-Picasa"); myPicasa.setUserCredentials("abc@gmail.com", "abc"); AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("abc")); PicasaFeed myPicasaFeed=myPicasa.Query(myAlbumQuery); foreach (PicasaEntry p in myPicasaFeed.Entries) { AlbumAccessor myAlbum = new AlbumAccessor(p); listBox1.Items.Add(myAlbum.AlbumTitle.ToString(); } }
This code snippet has been written to read single user Web Album information but you can read multi user web album information as well. Point to be noted here is if you are reading web album information of some user you can access only those web Albums which are in public domain. The security is well in place. The snapshot of complete code is below
I connected to my internet and run my C# form and click on the Get Picasa Albm Name button; and sure enough I got all my 6 Web Album titles in the list box. Please note when I was running the form I was connected with Internet as my client program (C# form) was pulling online information from Google Picasa services.
While running the code I came across this warning message 'Google.GData.Photos.AlbumAccessor' is obsolete: 'Use Google.Picasa.Album instead. This code will be removed soon'. I tried to find the documentation on this but I could not find much information on this but certainly I know this is something which should be taken care of in the future releases
Thanks for reading till this point. I hope you like the article.
If you want to explore more with the Source code of this post; please visit Download Zone.