Facebook graph api 如何使用app access token获取这些帖子的页面帖子和评论?
我想使用restfb创建一个应用程序,以获取任何页面的所有帖子和评论。我可以使用用户访问令牌来实现这一点,但使用应用访问令牌,我只能获得帖子,而不能获得评论。这可能是什么原因 下面的代码使用用户访问令牌来获取帖子和评论,但使用应用令牌,它不会给出评论Facebook graph api 如何使用app access token获取这些帖子的页面帖子和评论?,facebook-graph-api,restfb,Facebook Graph Api,Restfb,我想使用restfb创建一个应用程序,以获取任何页面的所有帖子和评论。我可以使用用户访问令牌来实现这一点,但使用应用访问令牌,我只能获得帖子,而不能获得评论。这可能是什么原因 下面的代码使用用户访问令牌来获取帖子和评论,但使用应用令牌,它不会给出评论 Page page = facebookClient.fetchObject("lockheedmartin", Page.class); System.out.println(page.getIsVerified()); System.out.p
Page page = facebookClient.fetchObject("lockheedmartin", Page.class);
System.out.println(page.getIsVerified());
System.out.println("bio: "+page.getCategory());
int totalResults = 0;
Connection<Post> pageFeed = facebookClient.fetchConnection(page.getId() + "/feed", Post.class,Parameter.with("limit", 20));
for (List<Post> feed : pageFeed) {
totalResults = totalResults + feed.size();
for (Post post : feed) {
com.restfb.types.Post.Comments comments = post.getComments();
if(comments !=null){
List<Comment> commentList = comments.getData();
for(Comment comment : commentList){
System.out.println(comment.getMessage());
}
}
}
}
Page page = facebookClient.fetchObject("lockheedmartin", Page.class);
int totalResults = 0;
Connection<Post> pageFeed = facebookClient.fetchConnection(page.getId() + "/feed", Post.class,Parameter.with("limit", 20));
for (List<Post> feed : pageFeed) {
totalResults = totalResults + feed.size();
for (Post post : feed) {
Connection<Comment> comments = facebookClient.fetchConnection(post.getId()+ "/comments", Comment.class);
if(comments !=null){
List<Comment> commentList = comments.getData();
for(Comment comment : commentList){
System.out.println(comment.getMessage());
}
}
}
}
Page Page=facebookClient.fetchObject(“lockheedmartin”,Page.class);
System.out.println(page.getIsVerified());
System.out.println(“bio:+page.getCategory());
int totalResults=0;
连接pageFeed=facebookClient.fetchConnection(page.getId()+“/feed”,Post.class,Parameter.with(“limit”,20));
对于(列表提要:页面提要){
totalResults=totalResults+feed.size();
for(Post:feed){
com.restfb.types.Post.Comments Comments=Post.getComments();
if(注释!=null){
List commentList=comments.getData();
对于(注释:注释列表){
System.out.println(comment.getMessage());
}
}
}
}
所以我不得不使用post的id来获取评论
Page page = facebookClient.fetchObject("lockheedmartin", Page.class);
System.out.println(page.getIsVerified());
System.out.println("bio: "+page.getCategory());
int totalResults = 0;
Connection<Post> pageFeed = facebookClient.fetchConnection(page.getId() + "/feed", Post.class,Parameter.with("limit", 20));
for (List<Post> feed : pageFeed) {
totalResults = totalResults + feed.size();
for (Post post : feed) {
com.restfb.types.Post.Comments comments = post.getComments();
if(comments !=null){
List<Comment> commentList = comments.getData();
for(Comment comment : commentList){
System.out.println(comment.getMessage());
}
}
}
}
Page page = facebookClient.fetchObject("lockheedmartin", Page.class);
int totalResults = 0;
Connection<Post> pageFeed = facebookClient.fetchConnection(page.getId() + "/feed", Post.class,Parameter.with("limit", 20));
for (List<Post> feed : pageFeed) {
totalResults = totalResults + feed.size();
for (Post post : feed) {
Connection<Comment> comments = facebookClient.fetchConnection(post.getId()+ "/comments", Comment.class);
if(comments !=null){
List<Comment> commentList = comments.getData();
for(Comment comment : commentList){
System.out.println(comment.getMessage());
}
}
}
}
Page Page=facebookClient.fetchObject(“lockheedmartin”,Page.class);
int totalResults=0;
连接pageFeed=facebookClient.fetchConnection(page.getId()+“/feed”,Post.class,Parameter.with(“limit”,20));
对于(列表提要:页面提要){
totalResults=totalResults+feed.size();
for(Post:feed){
ConnectionComments=facebookClient.fetchConnection(post.getId()+“/comments”,Comment.class);
if(注释!=null){
List commentList=comments.getData();
对于(注释:注释列表){
System.out.println(comment.getMessage());
}
}
}
}
页面很可能受到年龄或位置的限制,因此您必须使用用户或页面令牌。应用令牌与用户没有任何关系,因此Facebook不知道是否允许您查看内容
有关令牌的更多信息:
for(post:feed){Connection comments=facebookClient.fetchConnection(post.getId()+“/comments”,Comment.class);