-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeople.js
42 lines (37 loc) · 1.25 KB
/
people.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function myFunction() {
}
/**
* Gets a list of people in the user's contacts.
* @see https://developers.google.com/people/api/rest/v1/people.connections/list
*/
function getConnections() {
try {
// Get the list of connections/contacts of user's profile
const people = People.People.Connections.list('people/me', {
personFields: 'names,nicknames,emailAddresses,memberships,addresses'
});
// Print the connections/contacts
Logger.log('Connections: %s', JSON.stringify(people, null, 2));
} catch (err) {
// TODO (developers) - Handle exception here
console.log('Failed to get the connection with an error %s', err.message);
}
}
/**
* Gets the own user's profile.
* @see https://developers.google.com/people/api/rest/v1/people/getBatchGet
*/
function getSelf() {
try {
// Get own user's profile using People.getBatchGet() method
const people = People.People.getBatchGet({
resourceNames: ['people/me'],
personFields: 'names,nicknames,emailAddresses'
// Use other query parameter here if needed
});
Logger.log('Myself: %s', JSON.stringify(people, null, 2));
} catch (err) {
// TODO (developer) -Handle exception
console.log('Failed to get own profile with an error %s', err.message);
}
}