从facebook erro(java)检索对评论的回复
我试图使用restfb评论库的帮助和函数getcomments()从facebook获取对某些评论的回复 执行代码后,它会返回null,而不是对注释的回复 下面是我的代码快照从facebook erro(java)检索对评论的回复,java,facebook,restfb,Java,Facebook,Restfb,我试图使用restfb评论库的帮助和函数getcomments()从facebook获取对某些评论的回复 执行代码后,它会返回null,而不是对注释的回复 下面是我的代码快照 Connection<Comment> allComments = fbClient.fetchConnection(myArr1.get(xy)+"/comments", Comment.class); for(List<Comment> postcomments : allComments){
Connection<Comment> allComments = fbClient.fetchConnection(myArr1.get(xy)+"/comments", Comment.class);
for(List<Comment> postcomments : allComments){
for (Comment comment : postcomments){
String commentTemp = comment.getId() +" "+ comment.getFrom().getId() +" "+ comment.getCreatedTime() +" "+ comment.getMessage() +" "+ comment.getLikeCount() +" "+ comment.getComments()+" "+myArr1.get(xy);
}
}
Connection allComments=fbClient.fetchConnection(myArr1.get(xy)+“/comments”,Comment.class);
对于(列出后注释:所有注释){
对于(注释:后注释){
字符串commentTemp=comment.getId()+“”+comment.getFrom().getId()+“”+comment.getCreatedTime()+“”+comment.getMessage()+“”+comment.getLikeCount()+“”+comment.getComments()+“”+myArr1.get(xy);
}
}
除了comment.getcomments()之外,所有函数都会返回正确的值。您应该使用
注释id/comments
上的fetchConnection
。这可能有点贵,但您可以获取所有回复。您好,我正在使用restfb,发现了类似的问题;问题是connection.getData()只返回数据的第一页。我使用了迭代器,能够得到所有的评论。
请注意,即使是回复评论,你也必须做同样的事情;您将需要使用注释id而不是post id创建一个单独的连接,然后以如下所示的相同方式迭代注释
Connection<Comment> commentsConnection= fbClient.fetchConnection(post.getId()+"/comments",com.restfb.types.Comment.class);
if(commentsConnection!=null)
{
Iterator<List<Comment>> commentsIterator=commentsConnection.iterator();
while(commentsIterator.hasNext())
{
List<Comment> comments= commentsIterator.next();
for(Comment comment:comments)
{
String message=comment.getMessage();
}
}
}
connectioncommentsconnection=fbClient.fetchConnection(post.getId()+“/comments”,com.restfb.types.Comment.class);
if(commentsConnection!=null)
{
迭代器commentsIterator=commentsConnection.Iterator();
while(commentsIterator.hasNext())
{
List comments=commentsIterator.next();
对于(注释:注释)
{
String message=comment.getMessage();
}
}
}