2
votes

Hi I have done implementation of Google Contacts V3 API through Javascript Method(Javascript). Like below snipet:

//The google login url
https://www.googleapis.com/plus/v1/people/me
access_token='dsfjkasdkfjgasdf';


$.get("https://www.google.com/m8/feeds/contacts/default/full?access_token="+access_token+"&alt=json",{},function(xmldata) {
//console.log( xmldata.feed.entry );

var contacts =[];
$.each(xmldata.feed.entry,function(i,tag) {
    var contact_id=tag.id.$t;
    var name = tag.title.$t;
    var contact_emails = tag.gd$email; $.each(contact_emails,function(key,val){ social_email=val.address; });

    contacts.push({id:contact_id,name:name,email:social_email});

    console.log("id="+id+" name="+name+" email="+social_email+"\n");

    // store social contacts to db
});

},"json").fail(fail);

and successfull Response:

 {
"id": {
    "$t": "http://www.google.com/m8/feeds/contacts/{email}/base/{contact_id}"
},
"updated": {
    "$t": "2013-01-10T05:16:03.705Z"
},
"category": [
    {
        "scheme": "http://schemas.google.com/g/2005#kind",
        "term": "http://schemas.google.com/contact/2008#contact"
    }
],
"title": {
    "type": "text",
    "$t": ""
},
"link": [
    {
        "rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
        "type": "image/*",
        "href": "https://www.google.com/m8/feeds/photos/media/{email}/{contact_id}/9sadsdkj90"
    },
    {
        "rel": "self",
        "type": "application/atom+xml",
        "href": "https://www.google.com/m8/feeds/contacts/{email}/full/{contact_id}"
    },
    {
        "rel": "edit",
        "type": "application/atom+xml",
        "href": "https://www.google.com/m8/feeds/contacts/{email}/full/{contact_id}/1357794963705ffdd1"
    }
],
"gd$email": [
    {
        "rel": "http://schemas.google.com/g/2005#other",
        "address": "[email protected]",
        "primary": "true"
    }
]
}

Response is returning User Contact information, But I need Google plus id (i.e profile id ) also.

Please suggest me how can I get gid (Google+ id) from Contacts details (name,email,etc)? Please help to get profile id of all Contacts...

1
May i know why down vote? You can comment for any doubts? I know my English is not up to the mark...!ShivarajRH
I want to store gid (profile id) along with contact details...ShivarajRH

1 Answers

2
votes

For your authenticated user, the user's Google+ ID is the same as the OAuth 2.0 id and can be retrieved from an API call to the oauth2.tokeninfo endpoint by passing in your access token.

The response from tokeninfo will contain the following:

{
 "issued_to": "yourclientid.apps.googleusercontent.com",
 "audience": "yourclientid.apps.googleusercontent.com",
 "user_id": "{auth user's id}",
 "scope": ""
 "expires_in": 3584,
 "access_type": "online"
}

Now, what you may also be trying to do is retrieve the Google+ ids for people connected to a particular user. This is not possible through the Contacts API but it is possible to do by listing the people a user has made visible to your application in their Google+ circles.

The API there is plus.people.list.