问题
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