Tech Rocks

Coldfusion
Java
JQuery

An online resource for latest web technologies like Coldfusion, JRun, Pro*C, JQuery, HTML5, PHP, W3C, Java, J2EE, C, C++, ORACLE, PL/SQL, MySql, Ajax, Coldbox, Fusebox, UNIX, JavaScript, NodeJS and much more...

Thursday, September 12, 2013

Google Plus list activities - java api

List retval = new ArrayList();

Plus.Activities.List listActivities =
plusSvc.activities().list(userid, "public");

listActivities.setMaxResults(100L);

// get the 1st page of activity objects
ActivityFeed activityFeed = listActivities.execute();

// unwrap the request and extract the pieces we want
List pageOfActivities = activityFeed.getItems();

// loop through until we arrive at an empty page
while (pageOfActivities != null) {
for (Activity activity : pageOfActivities) {
retval.add(activity);
System.out.println("ID " + activity.getId() + " Content: " +
activity.getPlusObject().getContent());
}

// we will know we are on the last page when the next page token
// is null (in which case, break).
if (activityFeed.getNextPageToken() == null) {
break;
}

// prepare to request the next page of activities
listActivities.setPageToken(activityFeed.getNextPageToken());

// execute and process the next page request
activityFeed = listActivities.execute();
pageOfActivities = activityFeed.getItems();
}

0 comments :

Post a Comment