Get Access Token programmatically in Unit Test Method

若如初见. 提交于 2019-12-01 10:13:24

问题


First, I open Facebook Developers page, and I create new App. ( I get AppID, AppSecret values)

I want create Unit Test method for do Post to the wall, and later delete the post. publish_stream, publish_actions

Manually, I do this 3 steps

Open url

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

Then, this url opened, and I get the code value:

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

And then, open this url and I get the access token value: 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#=

Finally, I get the access token:

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

My code now is for my unit test is working. Only I need do the delete.

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

How can I do programmatically the 3 Manually steps ?

来源:https://stackoverflow.com/questions/26982904/get-access-token-programmatically-in-unit-test-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!