venerdì 26 ottobre 2012

C# Google API - Retrieve Google Contact Image

If we have a lot of contacts, it's very useful have the photo that help us to remember. 
The following code shows how to get google contact image

string qr = "YourContactUri".Replace("base", "full");
GDataCredentials Credentials = new GDataCredentials("", "yourPassword");
RequestSettings settings = new RequestSettings("appName", Credentials);
settings.UseSSL = true; //if you want to use ssl connection

ContactsRequest cr = new ContactsRequest(settings);
Contact contatto = cr.Retrieve<Contact>(new Uri(qr));
Image img = Image.FromStream(cr.Service.Query(contatto.PhotoUri));
pcb_foto.Image = img; //pcb_foto is a PictureBox put on the form

* if there is no image for the contact it need to manage the exception
** I want to remeber to go here to get  Application-specific password

My Two Cents...

Nessun commento:

Posta un commento