I was trying to write a program to retrieve all my activities from Google+. I studied the sample code provided by Google and wrote my program like this:
// Fetch the available activities
Plus.Activities.List listActivities = plus.activities().list("me", "public");
listActivities.setMaxResults(20L);
ActivityFeed feed;
try {
feed = listActivities.execute();
} catch (HttpResponseException e) {
log.severe(Util.extractError(e));
throw e;
}
// Keep track of the page number in case we're listing activities
// for a user with thousands of activities. We'll limit ourselves
// to 5 pages
int currentPageNumber = 0;
String token = "";
while (token != null && feed != null && feed.getItems() != null && currentPageNumber < 5) {
currentPageNumber++;
System.out.println();
System.out.println("~~~~~~~~~~~~~~~~~~ page "+currentPageNumber+" of activities ~~~~~~~~~~~~~~~~~~");
System.out.println();
for (Activity activity : feed.getItems()) {
show(activity);
System.out.println();
System.out.println("------------------------------------------------------");
System.out.println();
}
// Fetch the next page
token = feed.getNextPageToken();
System.out.println("next token: " + token);
listActivities.setPageToken(token);
feed = listActivities.execute();
}
The problem is that this only allows me to retrieve my "public" activities. I also have some private activities and this program didn't get them. The problem is related to
plus.activities().list("me", "public");
This list function requires an input parameter, the collection of activities to list. Here, it is "public". I want to retrieve all activities instead of just public ones. But based on
https://developers.google.com/+/api/latest/activities/list
The only available input for this collection of activities to list is "public". So my questions are:
- Is it possible to retrieve all my Activities (both public and non-public) from Google+ programmatically?
- If it is possible, how can I do it with Java?
Thanks a lot!