N D*_*are 8 java facebook facebook-graph-api facebook-comments
在Facebook Graph API中,我们可以获得给定用户的评论列表.
我还没有找到任何直接获取评论列表的方法.所以,我试图通过我的Feed找到它们,但它返回所有的Feed帖子.我们可以过滤我没有评论过的其他帖子吗?
我尝试了如下的各种查询,但无法得到我需要的内容.
/me/feed?fields=comments?fields=from?name="Nitin Thokare",message
/me/feed?fields=comments.fields(from.name("Nitin Thokare"),message)
Run Code Online (Sandbox Code Playgroud)
我需要(1)我的所有评论列表或其他(2)我评论过的帖子列表,过滤掉所有其他帖子.我们应该怎么做?(最后我将使用Java api来做同样的事情.)
小智 0
您可以使用 Spring 支持的 Facebook API 获取用户的评论列表。要访问用户的任何信息,您必须传递该特定用户的访问令牌。要获取评论列表,您必须通过传递访问令牌并使用获取 FeedOperations 对象来创建 FaceBookTemplate 对象。通过使用 FeedOperations 对象,您可以获得提要、帖子、状态、链接等。获取帖子列表并迭代每个帖子,并获取您对该帖子所做的所有评论。
FaceBook faceBook = new FaceBookTemplate(accessToken);
FeedOperations feeds=faceBook.feedOperations();
List<Post> posts=feeds.getPosts();
List<Comment> comments=new ArrayList<>();
for(Post post:posts){
List<Comment> commentsList = post.getComments();
for(Comment comment:commentsList){
comments.add(comment);
}
}
Run Code Online (Sandbox Code Playgroud)