为什么facebook4j的函数getcommentcount return null
Why does the function getcommentcount of facebook4j return null
我正在使用 facebook4j 来获取评论的回复数量,但实际上,无论 id_comment 是什么,它 returns null
这是我用来获取评论的代码;我在 excel 文件
中有 ID
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);
}
}
//这里是我如何使用函数
Comment commentaire = facebook.Commentaire(id_comment);
Integer Nb_reponse = commentaire.getCommentCount();
System.out.println("Nb_reponse"+Nb_reponse);
评论计数是非默认字段,因此您需要明确告诉 Facebook API 将其包含在响应中。您可以使用 Reading class 来实现:
Reading reading = new Reading().fields("comment_count");
facebook.getComment(commentId, reading);
你可以在facebook4j的官方documentation.
中找到更多
我正在使用 facebook4j 来获取评论的回复数量,但实际上,无论 id_comment 是什么,它 returns null 这是我用来获取评论的代码;我在 excel 文件
中有 IDenter 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);
}
} //这里是我如何使用函数
Comment commentaire = facebook.Commentaire(id_comment);
Integer Nb_reponse = commentaire.getCommentCount();
System.out.println("Nb_reponse"+Nb_reponse);
评论计数是非默认字段,因此您需要明确告诉 Facebook API 将其包含在响应中。您可以使用 Reading class 来实现:
Reading reading = new Reading().fields("comment_count");
facebook.getComment(commentId, reading);
你可以在facebook4j的官方documentation.
中找到更多