People: search

For large result sets, results are paginated. For the most up-to-date search results, do not use a pageToken older than five minutes. Instead, restart pagination by repeating the original request (omitting pageToken).

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 50, inclusive.
(Default: 25)

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. This token can be of any length.

Request body

Do not supply a request body with this method.

Response

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

Java

// 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.Search searchPeople = plus.people().search("Brett");
searchPeople.setMaxResults(5L);
PeopleFeed peopleFeed = searchPeople.execute();
List<Person> people = peopleFeed.getItems();
// Loop through until we arrive at an empty page, or the second page
int pageNumber = 1;
while (people != null && pageNumber <= 2) {
pageNumber++;
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
searchPeople.setPageToken(peopleFeed.getNextPageToken());
// Execute and process the next page request
peopleFeed = searchPeople.execute();
people = peopleFeed.getItems();
}