0

I want to send notification to GMail contact list of user. I am using this Google API code to fetch data:

var request = gapi.client.plus.people.list({  
    'userId': 'me',
    'collection': 'visible'
});

request.execute(function(resp) {  
    console.log('Num people visible:' + resp.totalItems);  
    console.log('JSON :: ' +JSON.stringify(resp) );  
});

I got all information in this form, except email of the user:

{  
    "kind":"plus#person",  
    "etag":"\"L2Xbn8bDuSErT6QA3PEQiwYKQxM/Cq8-fpfOKA7mSHBXOGvh5cXBraw\"",  
    "objectType":"person",  
    "id":"109949183447768127130",  
    "displayName":"Abhishek Singh",  
    "url":"https://plus.google.com/+AbhishekSinghLKO",  
    "image":{"url":"https://lh5.googleusercontent.com/-usIXgWialjY/AAAAAAAAAAI/AAAAAAAAAZ4/9G29gXNfwu0/photo.jpg?sz=50"}  
},

Is there any way to find all email ID corresponding to the data which I got from JSON?

Andrew T.
  • 4,701
  • 8
  • 43
  • 62
  • here i want to share a link of a site which i want but not able to do this .. how? https://www.moh.io/mohiomap/invite.php?gmail-logout – Arvind Kumar Sep 12 '14 at 12:15

3 Answers3

0

You need to include this in your scope: https://www.googleapis.com/auth/plus.profile.emails.read

The email address will be in the response in the callback.

For more information, see here

Donal
  • 31,121
  • 10
  • 63
  • 72
  • Thanks Donal i know different gplus scope but i can get only logged in email id not his friends email ids.is there any way to find out his friends contact list email ids – Arvind Kumar Sep 12 '14 at 12:10
  • That is a totally different question, you are looking for contacts. You need to look at the contacts API here: https://developers.google.com/google-apps/contacts/v3/ – Donal Sep 12 '14 at 12:15
  • I think this might help you: http://stackoverflow.com/questions/20017487/getting-google-contacts-with-javascript – Donal Sep 12 '14 at 12:16
  • thanks Donal i think you are right but i can understand how to use it please have a look in this link "https://www.moh.io/mohiomap/invite.php?gmail-logout" which i want to implement in my site http://hellotv.in/ – Arvind Kumar Sep 12 '14 at 12:19
  • @ArvindKumar I think that uses server side code. I think the only way to do it is using server side code. – Donal Sep 12 '14 at 12:25
  • Hi Donal there is any javaScript API for this implementation? – Arvind Kumar Sep 12 '14 at 12:28
  • Not that I am aware of. – Donal Sep 12 '14 at 13:41
0

It's a duplicate question of How to parse JSON in Java

import org.json.*;

public class jsonLoader() {
    public static JSONObject json(String jsonText) throws Exception {
        JSONObject json = new JSONObject(jsonText);
        return json;
    }
}

Long ID = json.get("id");

wrap the last line in a while loop solves the problem.

EDIT:

https://developers.google.com/+/api/latest/people/get showed only if users made their emails public, people.get returns email. The page you provided didn't show public email address.

Community
  • 1
  • 1
knh170
  • 2,960
  • 1
  • 11
  • 17
  • thanks for quick response but i think you are not getting me.I know how to parse json but problem is i am not getting email id of this data.How i can get email id of my friends. – Arvind Kumar Sep 12 '14 at 12:08
  • @ArvindKumar Do you mean email address? – knh170 Sep 12 '14 at 12:10
  • @ArvindKumar the Google+ page you provided doesn't show user email, thus the response won't include `userinfo.email`. – knh170 Sep 12 '14 at 12:14
0

you might want to take a look at this link, I think its what your looking for. I think the approaches might be to:

1) do your task in java, call javascript whenever you need and continue to do your tasks in java

2) create a class/function to send email notifications over by java and then call that function/object over in your javascript or method 1

Sending emails template via Java: http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/

Glen
  • 155
  • 1
  • 9