Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook graph api 如何使用app access token获取这些帖子的页面帖子和评论?_Facebook Graph Api_Restfb - Fatal编程技术网

Facebook graph api 如何使用app access token获取这些帖子的页面帖子和评论?

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

我想使用restfb创建一个应用程序,以获取任何页面的所有帖子和评论。我可以使用用户访问令牌来实现这一点,但使用应用访问令牌,我只能获得帖子,而不能获得评论。这可能是什么原因

下面的代码使用用户访问令牌来获取帖子和评论,但使用应用令牌,它不会给出评论

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不知道是否允许您查看内容

有关令牌的更多信息:


不过我可以通过帖子的id获得评论。那么重点是什么呢?哦,我的错,我没有仔细阅读-好吧,那样的话,我们需要更多的信息。请将您的代码添加到您的问题中,或者至少添加确切的api调用。完成。请检查:)请提供页面id和测试的帖子id“lockheedmartin”是页面名称。正在此处获取帖子id:
for(post:feed){Connection comments=facebookClient.fetchConnection(post.getId()+“/comments”,Comment.class);