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



我正在编写一个简单的Java程序,用于获取/编辑/删除Facebook群组的墙帖。我可以获取和删除我选择的任何墙帖,但我不知道如何编辑特定的帖子。

这是我尝试的解决方案

    // 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()));
        }
    } 

现在我为您推荐一个强大的技巧来编辑特定的墙帖。这是Facebook4J。它很容易使用。

贴墙:

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

删除帖子,你可以删除更多的对象,如照片,评论

facebook.deletePost(postId);

获取消息:

facebook.getMessage(messageId)

有关更多信息,请参阅Facebook4J

最新更新