简体   繁体   English

如何使用RestFB编辑Facebook墙上的帖子?

[英]How do I edit Facebook wall posts using RestFB?

I'm writing a simple Java program that gets/edits/deletes the wall posts of a Facebook group. 我正在编写一个简单的Java程序,该程序可以获取/编辑/删除Facebook组的墙贴。 I'm able to get and delete any wall post that I choose, but I don't know how to edit a particular post. 我可以获取和删除自己选择的所有墙贴,但是我不知道如何编辑特定的墙贴。

Here's my attempted solution 这是我尝试的解决方案

    // Get all posts on wall
    Connection<Post> restFbPosts = facebookClient.fetchConnection("fakepage/posts", Post.class);

    for (Post post : restFbPosts.getData()) {
        // Want to edit the post with message "test"
        if (post.getMessage().equals("test")) {
            post.setMessage("test post is modified");

            facebookClient.deleteObject(post.getId());
            facebookClient.publish("fakepage/feed", FacebookType.class, Parameter.with("message", post.getMessage()));
        }
    } 

Now i suggest powerful tip for you edit particular wall post. 现在,我为您建议编辑特定墙贴的有力技巧。 That's Facebook4J. 那是Facebook4J。 It's very easy to use. 它很容易使用。

Post to wall: 发布到墙上:

PostUpdate update = new PostUpdate("Hello World");
String returnPostId=facebook.postFeed(userID,update);//or Group_ID

Delete Post, You can delete more object like Photo, Comment 删除帖子,您可以删除更多对象,例如照片,评论

facebook.deletePost(postId);

Get Message: 取得讯息:

facebook.getMessage(messageId)

For more infomation, see Facebook4J 有关更多信息,请参阅Facebook4J。

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

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