在unit testing方法中以编程方式获取访问令牌
首先,我打开Facebook Developers页面,然后创建新的App。 (我得到AppID,AppSecret值)
我想创建unit testing方法for post to the wall,然后删除post。 publish_stream,publish_actions
手动 ,我做了3个步骤
打开url
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";
我的代码现在是我的unit testing工作。 只有我需要删除。
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个手动步骤?