Listing people in circles

The Google+ Domains API allows your app to list all of the users in a specified circle within your G Suite domain.

To list the people in a circle, your app must request the following scopes:

https://www.googleapis.com/auth/plus.me
Grants the app permission to use the special value me to represent the authenticated user. Does not apply to apps that use domain-wide delegation of authority.
https://www.googleapis.com/auth/plus.circles.read
Required - Grants the app permission to read the names of the user's circles, and the people and pages that are members of each circle.

Listing the circles for a user

The following example demonstrates how to fetch a list of all of the people in a circle within your G Suite domain.

Java

// This sample assumes a client object `plusDomains` has been created
// and that you know the ID of the circle you want to lookup.
// To learn more about creating a client, see the OAuth 2.0 example:
//  https://developers.google.com/+/domains/authentication/

import com.google.api.services.plusDomains.model.PeopleFeed;

String circleId = "a1234b";

PlusDomains.People.ListByCircle listPeople = plusDomains.people().listByCircle(circleId);
listPeople.setMaxResults(100L);

PeopleFeed peopleFeed = listPeople.execute();
System.out.println("Google+ users circled:");

// This example only displays one page of results.
if(peopleFeed.getItems() != null && peopleFeed.getItems().size() > 0 ) {
  for(Person person : peopleFeed.getItems()) {
    System.out.println("\t" + person.getDisplayName());
  }
}

Python

# This sample assumes a client object `service` has been created and
# that you know the ID of the circle you want to lookup.
# To learn more about creating a client, see the OAuth 2.0 example:
#  https://developers.google.com/+/domains/authentication/

circle_id = 'a1234b'

people_service = service.people()
people_list = people_service.listByCircle(circleId=circle_id).execute()

print 'Google+ users circled: '
for user in people_list['items']:
  print '\t %s' % user.get('displayName')

Protocol

See the People.listByCircle REST API method.

Enviar comentarios sobre…