简体   繁体   English

使用SDK C#删除Wall Facebook帖子

[英]Delete Post of Wall Facebook using SDK C#

I newbie using Facebook SDK for C# 我新手使用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. Post方法获取Postid(id属性),您可以将其用于删除帖子。

https://developers.facebook.com/docs/graph-api/reference/v2.2/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 . 您需要一个带有publish_actions的用户令牌才能向/post-id发出DELETE请求。

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

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