简体   繁体   English

用facebook4j回复评论

[英]Replying to comment with facebook4j

I want to reply a comment of my page's post with facebook4j. 我想用facebook4j回复我的页面帖子的评论。 Now I can only retrieve replies of comment. 现在,我只能检索评论的回复。 I can't reply the comment. 我无法回复评论。 I have comment id. 我有评论ID。 What should I do? 我该怎么办? Does facebook4j support to reply specific comment? facebook4j是否支持回复特定评论? Thanks 谢谢

Either facebook4j or the FB Graph API changed a bit since I last tried this and had it working, so I played with it a bit and found a new solution that works. 自从我上次尝试并使其正常运行以来,facebook4j或FB Graph API都发生了一些变化,因此我进行了一些尝试,找到了一个可行的新解决方案。

First, you'll need to get your Facebook page ID (you can do that here: https://findmyfbid.com/ ) 首先,您需要获取您的Facebook页面ID(可以在此处进行操作: https : //findmyfbid.com/

Once you have this, create your post as you currently do, and make sure you capture the return post-id. 收到邮件后,请按当前方式创建帖子,并确保捕获返回的帖子ID。

String postID = fb.postFeed(your-post-object);

It used to be that the return value was a string like [page-id]_[post-id] , but now it seems to only return [post-id] . 过去,返回值是[page-id]_[post-id]类的字符串,但现在看来只返回[post-id]

When posting a comment, it expects that first form, so instead of only giving the commentPost() method the post-id, give it both the page- and post-id. 在发布评论时,它期望使用第一种形式,因此,不仅要给commentPost()方法加上post-id,还要给它提供page-和post-id。

//String commentID = fb.commentPost(postID, your-comment-object);
// ^ this was the old way, which no longer works

String commentID = fb.commentPost(pageID + "_" + postID, your-comment-object);

The return value is in the form [post-id]_[comment-id] . 返回值的形式为[post-id]_[comment-id] If you now want to go one level further and post replies on that comment, you can use commentPost() again, with the target object being of the form [page-id]_[post-id]_[comment-id] . 如果现在想更进一步并发表评论,则可以再次使用commentPost(),目标对象的形式为[page-id]_[post-id]_[comment-id] Since the returned commentID string already contains the post-id, it doesn't need added again here. 由于返回的commentID字符串已包含后ID,因此无需在此处再次添加。

String replyID = fb.commentPost(pageID + "_" + commentID, your-reply-object);

The reply object is either a String or a CommentUpdate object, same as with posting a regular comment. 回复对象是String或CommentUpdate对象,与发布常规评论相同。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM