1

首先,我打开 Facebook 开发者页面,然后创建新应用程序。(我得到 AppID,AppSecret 值)

我想为做发布到墙上创建单元测试方法,然后删除该帖子。 发布流,发布操作

手动,我做这 3 个步骤

打开网址

https://graph.facebook.com/oauth/authorize?client_id=xxxxx&redirect_uri=http://www.kiquenet.com/&scope=publish_stream,publish_actions

然后,这个 url 打开,我得到了代码值

http://www.kiquenet.com/?code=A....3qhOw# =

然后,打开这个 url,我得到访问令牌值: https://graph.facebook.com/oauth/access_token?client_id=xxxxx&redirect_uri=http://www.kiquenet.com/&scope=publish_stream,publish_actions&client_secret=zzzzz&code= A...3qhOw# =

最后,我得到了访问令牌:

  const string token = "C...SNo";

我的代码现在用于我的单元测试正在运行。只有我需要删除。

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 ???
        }

如何以编程方式执行 3 个手动步骤?

4

0 回答 0