Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google API : Getting a Contacts Photo

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

like image 340
Gogo_Z Avatar asked May 12 '11 19:05

Gogo_Z


People also ask

How do I get my contact photos from Google?

Open the contact. Under the contact name, scroll down for Google Profile. If you right click on the photo, you have the option to save or download the image.

Is there an API for Google Photos?

Using the Google Photos Library API your app can read, write, and share photos and videos in Google Photos. The Library API is a RESTful API with JSON payload. The structure of the API is based on the product concepts of Google Photos: Library: media stored in the user's Google Photos account.

How do I access my Google Contacts API?

To access personal contacts: https://www.googleapis.com/auth/contacts. To access directory information: https://www.googleapis.com/auth/directory.readonly. Note: The Domain Shared Contacts API is not affected by these changes.


2 Answers

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

like image 180
Savil Avatar answered Jun 17 '23 16:06

Savil


Just a small hint, according to Google's API docs:

Note: If a contact does not have a photo, then the photo link element has no gd:etag attribute.

More info here

like image 23
ganoro Avatar answered Jun 17 '23 18:06

ganoro