Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Contacts API - getting image

I'm having a simple problem while retrieving user's contact's images. So I make a request to

$url = 'https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=9999&oauth_token=' . $accessToken;

And then I get huge JSON from which I have extracted full name and email. Then I tried getting contact's image, and haven't had any success.

I get with all contacts, and everyone has following structure:

entry [id, updated, category, title, link, gd$email].

In the link section, I got four links, of which first two are some kind of link to an image content but I cannot retrieve it.

Any body had any success in doing this kind of work !?

Tnx alot!

BTW: If some data from my case is missing, please report and I'll add it too!

EDIT: I have also tried to reach the image with URL

 http://profiles.google.com/s2/photos/profile/" + userid + "?sz=" + size;

but the problem is I cannot get userId from contacts JSON.

like image 285
Adrian Avatar asked Nov 02 '22 12:11

Adrian


1 Answers

You must call the photo endpoint and append to it a valid access token as a query parameter.

Example:

https://www.google.com/m8/feeds/photos/media/name.surname%40gmail.com/0?access_token=ACCESS_TOKEN

Docs:

https://developers.google.com/google-apps/contacts/v3/#contact_photo_management

like image 112
db80 Avatar answered Nov 09 '22 07:11

db80