1

I'm using facebook4j to get the Number of replies of a comment but, actually, it returns null whatever the id_comment is Here is the code that i'm using to get the comment ; i have the ids in an excel file

enter code herepublic class RecuperationFacebook {
public static String appId = "appId";
public static String appSecret = "appSecret";
public static String access_token = "";
public static Facebook facebook ;
public RecuperationFacebook()
{
    facebook = new FacebookFactory().getInstance();
    facebook.setOAuthAppId(appId, appSecret);
    facebook.setOAuthAccessToken(new AccessToken(access_token));
}
public static Comment Commentaire(String id_comment) throws FacebookException
{
          Comment commentaire =facebook.getComment(id_comment, null);
          commentaire.getFrom().getId();
          return(commentaire);

}

} //and here is how i'm using the function

Comment commentaire = facebook.Commentaire(id_comment);
        Integer Nb_reponse = commentaire.getCommentCount();
        System.out.println("Nb_reponse"+Nb_reponse);

1 Answers1

0

The comment count is a non-default field so you need to explicitly tell the Facebook API to include it in the response. You can use the Reading class to achieve this:

Reading reading = new Reading().fields("comment_count");
facebook.getComment(commentId, reading);

You can find out more in facebook4j's official documentation.

c-w
  • 66
  • 1
  • 4