【发布时间】:2017-04-18 18:58:09
【问题描述】:
我正在使用 RestFB 从 facebook 页面获取帖子。问题是我只想要页面的最新帖子,比如说上个月的帖子。使用我的代码,我可以获得所有历史记录,这需要很多时间。 我怎么做?我还没有读过“时间戳”参数。我尝试过使用限制参数,但没有得到很好的结果。
我的代码是:
public static JSONArray GetPostsFromPage(String idpage) {
String texto, idpost;
Date timestamp;
JSONArray array = new JSONArray();
JSONObject objeto;
Connection<Post> postFeed = fbClient.fetchConnection(idpage + "/feed", Post.class, Parameter.with("limit", 50));
for (List<Post> postPage : postFeed) {
for (Post aPost : postPage) {
objeto = new JSONObject();
idpost = aPost.getId();
texto = aPost.getMessage();
timestamp = aPost.getCreatedTime();
objeto.put("id", idpost);
objeto.put("texto", texto);
objeto.put("timestamp", timestamp);
array.put(objeto);
}
}
return array;
}
欢迎任何想法。谢谢。
【问题讨论】:
标签: java facebook facebook-graph-api restfb