public static IList<Person> PeopleListByActivityPaging(PlusService service, string _activityId, PeopleResource.ListByActivityRequest.CollectionEnum _type, int NumberOfPages, int ItemsPerPage, string NextPageToken) { int max = ItemsPerPage; int count = 0; int iterate = NumberOfPages; PeopleResource.ListByActivityRequest list = service.People.ListByActivity(_activityId, _type); list.MaxResults = max; PeopleFeed peopleFeed = list.Execute(); IList<Person> people = new List<Person>(); count++; //// Loop through until we arrive at an empty page while (peopleFeed.Items != null || count <= iterate) { // Prepare the next page of results list.PageToken = peopleFeed.NextPageToken; // Adding each item to the list. foreach (Person item in peopleFeed.Items) { people.Add(item); } // We will know we are on the last page when the next page token is // null. // If this is the case, break. if (peopleFeed.NextPageToken == null || count >= iterate) { break; } // Execute and process the next page request peopleFeed = list.Execute(); count++; } Person token = new Person(); token.DisplayName = peopleFeed.NextPageToken; people.Add(token); return people; }
/// <summary> /// List all of the people in the specified collection for a particular activity. /// The collection parameter specifies which people to list, such as people who have +1'd or reshared this activity. /// Documentation: https://developers.google.com/+/api/latest/people/listByActivity /// </summary> /// <param name="service"></param> /// <param name="_activityId">The ID of the activity to get the list of people for.</param> /// <param name="_type">plusoners or resharers</param> /// <returns></returns> public static IList<Person> PeopleListByActivity(PlusService service, string _activityId, PeopleResource.ListByActivityRequest.CollectionEnum _type) { PeopleResource.ListByActivityRequest list = service.People.ListByActivity(_activityId, _type); list.MaxResults = 100; PeopleFeed peopleFeed = list.Execute(); IList<Person> people = new List<Person>(); //// Loop through until we arrive at an empty page while (peopleFeed.Items != null) { // Adding each item to the list. foreach (Person item in peopleFeed.Items) { people.Add(item); } // We will know we are on the last page when the next page token is // null. // If this is the case, break. if (peopleFeed.NextPageToken == null) { break; } // Prepare the next page of results list.PageToken = peopleFeed.NextPageToken; // Execute and process the next page request peopleFeed = list.Execute(); } return people; }