我正在尝试编写一个程序来从 Google+ 中检索我的所有活动。我研究了谷歌提供的示例代码,我的程序是这样写的:
// 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();
}
问题是这只允许我检索我的“公共”活动。我也有一些私人活动,但这个程序没有得到它们。问题与
plus.activities().list("me", "public");
此列表函数需要一个输入参数,即要列出的活动集合。在这里,它是“公共的”。我想检索所有活动,而不仅仅是公共活动。但基于
https://developers.google.com/+/api/latest/activities/list
要列出的此活动集合的唯一可用输入是“公共”。所以我的问题是:
- 是否可以以编程方式从 Google+ 检索我的所有活动(公开和非公开)?
- 如果可能的话,我怎么能用Java做到这一点?
非常感谢!