Google API : Getting a Contacts Photo

Gogo_Z picture Gogo_Z · May 12, 2011 · Viewed 8.5k times · Source

I've been able to retrieve everything but the contacts photo by following the API.

I can get the img url as well as the gd:etag from the xml returned. Below is the Google API example, and it is the same thing I get, with the value of the attributes being different of course for my contacts.

    <link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*'
  href='https://www.google.com/m8/feeds/photos/media/liz%40gmail.com/c9012de'
  gd:etag='"KTlcZWs1bCp7ImBBPV43VUV4LXEZCXERZAc."'>

The problem is I don't know how to get it to display. When I try it, I just get the last part of the url (ie: "/32432eewqdweq") and no image.

I'm using rails, and this is my second week of doing web development, sorry if I seem noobish aha.

Any help would be appreciated!

Thanks,

Goran

Answer

Savil picture Savil · Oct 3, 2011

You would need to make a request to the url, but also include the access_token as a query parameter.

So, using your example, let's say if your access_token is ABCDEF123456ABCDEF, then the GET request you want to make is:

https://www.google.com/m8/feeds/photos/media/liz%40gmail.com/c9012de?access_token=ABCDEF123456ABCDEF