Android: 如何按顺序从 Facebook 获取大量数据
Android: How to fetch significant amounts of data from Facebook in order
我想获取我的墙贴,当然很多,我想一块一块地获取它们以避免长时间等待(假设限制:一次10个),我怎么能完成这个?
我使用下面的代码获取前 10 个帖子,但稍后如果需要,我想获取下一个/后面的 10 个帖子,依此类推.
public void getMeWatchedWantsToWatch()
{
String pods = "/me/feed";
Bundle params = new Bundle();
params.putString("limit", "10");
new Request(session, pods, params, HttpMethod.GET, new Request.Callback()
{
public void onCompleted(Response response)
{
}
}
).executeAsync();
}
谢谢:)
编辑 1:
对不起,当我使用
进行分页时
new Request().newGraphPathRequest(Session.getActiveSession(), mNextPageURL, new Request.Callback()
我在响应中遇到错误
(#100) Tried accessing nonexisting field (data) on node type (URL)
and (data) 是我在第一个请求中指定的字段,它工作正常,我从中获取了我的数据和分页 url,所以我在这里缺少什么! – Astrount 1 分钟前
编辑 2:
我终于在我的寻呼请求中找到了问题的根源,我必须删除“https://graph.facebook.com/" from the paging "next" value before I send it in my request:当然我必须在寻呼"next"请求中指定相同的"fields:id, name, etc."作为在我的第一个请求中。
你需要实现的是分页,在结果中搜索分页link然后API调用"next"link得到下一批:https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging
顺便说一句,我假设您使用的是 read_stream
,因此您可能需要阅读以下内容:https://developers.facebook.com/docs/facebook-login/permissions/v2.2#reference-read_stream
read_stream
将不会获得 Android 应用程序的批准。您可以尝试使用 user_status
权限并改为调用 /me/statuses
,只有您墙上的朋友帖子不包括在内。
我想获取我的墙贴,当然很多,我想一块一块地获取它们以避免长时间等待(假设限制:一次10个),我怎么能完成这个?
我使用下面的代码获取前 10 个帖子,但稍后如果需要,我想获取下一个/后面的 10 个帖子,依此类推.
public void getMeWatchedWantsToWatch()
{
String pods = "/me/feed";
Bundle params = new Bundle();
params.putString("limit", "10");
new Request(session, pods, params, HttpMethod.GET, new Request.Callback()
{
public void onCompleted(Response response)
{
}
}
).executeAsync();
}
谢谢:)
编辑 1:
对不起,当我使用
进行分页时new Request().newGraphPathRequest(Session.getActiveSession(), mNextPageURL, new Request.Callback()
我在响应中遇到错误
(#100) Tried accessing nonexisting field (data) on node type (URL)
and (data) 是我在第一个请求中指定的字段,它工作正常,我从中获取了我的数据和分页 url,所以我在这里缺少什么! – Astrount 1 分钟前
编辑 2:
我终于在我的寻呼请求中找到了问题的根源,我必须删除“https://graph.facebook.com/" from the paging "next" value before I send it in my request:当然我必须在寻呼"next"请求中指定相同的"fields:id, name, etc."作为在我的第一个请求中。
你需要实现的是分页,在结果中搜索分页link然后API调用"next"link得到下一批:https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging
顺便说一句,我假设您使用的是 read_stream
,因此您可能需要阅读以下内容:https://developers.facebook.com/docs/facebook-login/permissions/v2.2#reference-read_stream
read_stream
将不会获得 Android 应用程序的批准。您可以尝试使用 user_status
权限并改为调用 /me/statuses
,只有您墙上的朋友帖子不包括在内。