我正在尝试使用 facebook4j 检索有关 facebook 帖子的所有基本信息。
这是我的代码:
final Reading reading1 = new Reading().since("-1 month").limit(38).fields("comments", "likes", "id", "message", "caption", "description", "created_time", "from").summary();
final ResponseList<Post> feeds1 = facebook.getPosts("viratkohli", reading1);
final Reading reading2 = new Reading().since("-1 month").fields("likes", "id", "message", "created_time", "from", "story").limit(100).summary();
final ResponseList<Post> feeds2 = facebook.getPosts("viratkohli", reading2);
for (int i = 0; i < feeds2.size(); i++) {
// Get post.
Post post1 = feeds2.get(i);
// Get (string) message.
String message = post1.getMessage();
Date d = post1.getCreatedTime();
String id = post1.getId();
PagableList<Like> pl = post1.getLikes();
String story = post1.getStory();
System.out.println("post: "+i+": "+message);
System.out.println("Created time: "+d.toString());
System.out.println("id: "+id);
System.out.println("story: "+story);
System.out.println();
for(Like like: pl) {
String like_name = like.getName();
String like_id = like.getId();
System.out.println("like name: "+like_name);
System.out.println("like id: "+like_id);
System.out.println();
}
System.out.println("******************");
}
for(int j=0;j<feeds1.size();j++){
Post post2 = feeds1.get(j);
System.out.println(j);
final PagableList<Comment> comments = post2.getComments();
for(int k=0; k<comments.size(); k++) {
// Get comment.
Comment comment = comments.get(k);
String id2 = comment.getId();
String comm = comment.getMessage();
Date d2 = comment.getCreatedTime();
Integer co = comment.getLikeCount();
System.out.println("Comment "+k+": "+comm);
System.out.println("id: "+id2);
System.out.println("created time: "+d2);
}
System.out.println("~~~~~~~~~~~~~");
}
目前,我可以获得以下信息:
最大限度。100 个最近的帖子,25 个最近的喜欢,每个帖子的 25 个最近的评论(最多 40 个帖子)。
任何克服限制问题的帮助将不胜感激。