gpt4 book ai didi

android - 查看android上google plus的 Activity 列表

转载 作者:行者123 更新时间:2023-11-30 03:16:18 24 4
gpt4 key购买 nike

我正在关注 google plus list 的文档并且我正在使用此代码:

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+ Java quickstart , 请参阅 source file in question了解如何设置凭据和 Plus 客户端。您还需要授权您的请求,该示例项目展示了如何使用 Google+ 登录授权用户获取访问 token 。您必须拥有授权用户才能使用 “我” 进行搜索。

此示例是使用 Google Java API 客户端库的 Java 代码,Android SDK 默认不包含客户端库,因此您需要将其导入到您的项目中。

关于android - 查看android上google plus的 Activity 列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20049870/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com