简体   繁体   中英

Delete Post of Wall Facebook using SDK C#

I newbie using Facebook SDK for C#

I have seen this post to wall in unit test. Get Access Token programmatically in Unit Test Method

Now, I want to delete post in my wall.

using Facebook;
        [TestMethod]
        public void Post_to_the_wall()
        {

            var client = new FacebookClient(token);
            dynamic parameters = new ExpandoObject();
            parameters.message = "Check out this funny article";
            parameters.link = "http://www.example.com/article.html";
            parameters.picture = "http://www.example.com/article-thumbnail.jpg";
            parameters.name = "Article Title";
            parameters.caption = "Caption for the link";
            parameters.description = "Longer description of the link";
            parameters.actions = new
            {
                name = "View on Zombo",
                link = "http://www.zombo.com",
            };
            parameters.privacy = new
            {
                value = "ALL_FRIENDS",
            };

            dynamic result = client.Post("me/feed", parameters);

           // TODO: NOW, delete the post ???
        }

Any suggestions ?

Simply do this:

 dynamic result = client.Post("me/feed", parameters);

 client.Delete(result.id);

Post method get Postid (id property), and you can use it for delete the post.

https://developers.facebook.com/docs/graph-api/reference/v2.2/post

An app can delete a post if it published it

Check out the example code on that page. You need a User Token with publish_actions to make a DELETE request to /post-id .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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