Google Contacts API Example 2013 June 29

In my previous blog Google Authentication I wrote how to get an access token from Google to be able to consume its services. In this post I will use this access token to access Google Contacts API. This is just a basic implementation. I highly recommend for more advanced features take a look the official documentation. Let's look at the code first:

WebClient client = new WebClient(); 
var content = client.DownloadString("https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=10000&access_token=" + access_token); 
jsonContent = Json.Decode(content); 

That's it! Very simple. Use the access token that you have from OAuth 2.0 authentication procedure, set the parameters (for a list of parameters click here), and send a request to the contacts URL. Again I used JSON to decode the retrieved response. The start of the response starts with details about the account which the data is retrieved from. The contacts data start from the "entry" node where all the contacts (up to the max limit) are stored in an array.