Google+ Platform

People: listByActivity

List all of the people in the specified collection for a particular activity. Try it now or see an example.

The collection parameter specifies which people to list, such as people who have +1'd or reshared this activity. For large collections, results are paginated.

Each item in the response of this method contains basic fields of a person resource, including id, displayName, image, and url. To get a full person resource, use people.get.

Request

HTTP request

GET https://www.googleapis.com/plus/v1/activities/activityId/people/collection

Parameters

Parameter name Value Description
Required parameters
activityId string The ID of the activity to get the list of people for.
collection string The collection of people to list.

Acceptable values are:
  • "plusoners": List all people who have +1'd this activity.
  • "resharers": List all people who have reshared this activity.
Optional parameters
maxResults unsigned integer The maximum number of people to include in the response, which is used for paging. For any response, the actual number returned might be less than the specified maxResults. Acceptable values are 1 to 100, inclusive. (Default: 20)
pageToken string The continuation token, which is used to page through large result sets. To get the next page of results, set this parameter to the value of "nextPageToken" from the previous response.

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a response body with the following structure:

{
  "kind": "plus#peopleFeed",
  "etag": etag,
  "selfLink": string,
  "title": string,
  "nextPageToken": string,
  "totalItems": integer,
  "items": [
    people Resource
  ]
}
Property name Value Description Notes
kind string Identifies this resource as a collection of people. Value: "plus#peopleFeed".
title string The title of this collection of people.
nextPageToken string The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
items[] list The people in this page of results. Each item includes the id, displayName, image, and url for the person. To retrieve additional profile data, see the people.get method.
etag etag ETag of this response for caching purposes.
totalItems integer The total number of people available in this list. The number of people in a response might be smaller due to paging. This might not be set for all collections.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library

// This sample assumes a client object has been created.
// To learn more about creating a client, check out the starter:
//  https://developers.google.com/+/quickstart/java

Plus.People.ListByActivity listPeople =
    plus.people().listByActivity(activityId, "plusoners");
listPeople.setMaxResults(5L);

PeopleFeed peopleFeed = listPeople.execute();
List<Person> people = peopleFeed.getItems();

// Loop through until we arrive at an empty page
while (people != null) {
  for (Person person : people) {
    System.out.println(person.getDisplayName());
  }

  // We will know we are on the last page when the next page token is null.
  // If this is the case, break.
  if (peopleFeed.getNextPageToken() == null) {
    break;
  }

  // Prepare the next page of results
  listPeople.setPageToken(peopleFeed.getNextPageToken());

  // Execute and process the next page request
  peopleFeed = listPeople.execute();
  people = peopleFeed.getItems();
}

PHP

Uses the PHP client library

# This sample assumes a client object has been created.
# To learn more about creating a client, check out the starter:
#  https://developers.google.com/+/quickstart/php

$optParams = array('maxResults' => '20');
$plusoners = $plus->people->listByActivity(
    "z12gtjhq3qn2xxl2o224exwiqruvtda0i", "plusoners", $optParams);
foreach($plusoners['items'] as $person) {
  print "{$person['displayName']} +1'ed the post\n";
}

Python

Uses the Python client library

# This sample assumes a client object has been created. # To learn more about creating a client, check out the starter: # https://developers.google.com/+/quickstart/python

people_resource = service.people() request = people_resource.listByActivity( activityId=activity_id, collection='plusoners', maxResults='2') print "+1'ers:" while request != None: people_document = request.execute() if 'items' in people_document: print 'got page with %d' % len( people_document['items'] ) for person in people_document['items']: print person['id'], person['displayName'] request = service.activities().list_next(request, people_document) print "----------------------"

Ruby

Uses the Ruby client library

# This sample assumes a client object has been created.
# To learn more about creating a client, check out the starter:
#  https://developers.google.com/+/quickstart/ruby

status, headers, body = client.execute(
  plus.people.list_by_activity,
  {'activityId' => id,
   'collection' => 'plusoners',
   'maxResults' =>'3'})

return status if status != 200

response = JSON.parse(body[0])
people = response['items']

# We have some peopl, but we need to keep paging through them to get all of them
while response['nextPageToken'] do
  status, headers, body = client.execute(
      plus.people.list_by_activity,
      {'activityId' => id,
       'collection' => 'plusoners',
       'maxResults' => '3',
       'pageToken' => response['nextPageToken']})

  response = JSON.parse(body[0])

  return status if status != 200

  puts "Got #{people.size} people so far.  NPT #{response['nextPageToken']}"

  people += response['items'] unless !response['items']
end

# Print out the collected people
for person in people
  puts "+1'er: #{person['id']}: #{person['displayName']}"
end

Go

Uses the Go client library

people, err := plusService.People.ListByActivity(activityId, "plusoners").Do()

JavaScript

Uses the JavaScript client library

// This sample assumes a client object has been created.
// To learn more about creating a client, check out the starter:
//  https://developers.google.com/+/quickstart/javascript
var request = gapi.client.plus.people.listByActivity({
'activityId' : activityId, 'collection' : 'plusoners' }); request.execute(function(resp) { var numItems = resp.items.length; for (var i = 0; i < numItems; i++) { console.log(resp.items[i].displayName); } });

Try it!

Use the APIs Explorer below to call this method on live data and see the response. Alternatively, try the standalone Explorer.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.