【发布时间】:2023-12-27 12:56:01
【问题描述】:
我按照本教程使用 Google+ API 成功登录了我的 Google Plus 帐户:
Android Login with Google Plus Account
并获得了一些用户的信息(姓名、电子邮件、个人资料 URL、图片等)。
我面临的问题是我无法获取用户的活动(我的意思是用户“墙”上的最后帖子)。 我知道使用 Google Plus API 我只能获得公共活动,但我什至无法获得这些。 我使用的代码是
// 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.Activities.List listActivities = plus.activities().list("me", "public");
listActivities.setMaxResults(5L);
// Execute the request for the first page
ActivityFeed activityFeed = listActivities.execute();
// Unwrap the request and extract the pieces we want
List<Activity> activities = activityFeed.getItems();
// Loop through until we arrive at an empty page
while (activities != null) {
for (Activity activity : activities) {
System.out.println("ID " + activity.getId() + " Content: " +
activity.getObject().getContent());
}
// We will know we are on the last page when the next page token is null.
// If this is the 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();
activities = activityFeed.getItems();
}
我是从 Google+ API 官方网站获得的,地址是:
Google+ Platform: Activities: list
当我尝试编译和运行时,我会收到以下错误消息:
Error:Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
Error:(207, 21) error: cannot find symbol class Activities
Error:(207, 55) error: cannot find symbol variable plus
Error:(211, 17) error: cannot find symbol class ActivityFeed
Error:(214, 17) error: cannot find symbol class List
Error:(219, 60) error: cannot find symbol method getId()
Error:(220, 41) error: cannot find symbol method getObject()
有人可以帮助我吗? 非常感谢。
【问题讨论】:
标签: java android google-plus google-signin