publish on Facebook application page as an application using Facebook c# sdk
I need to publish a post on my application profile page as an application not as a user here is the code :
var fb = new FacebookOAuthClient(FacebookApplication.Current);
dynamic resultt = fb.GetApplicationAccessToken();
var appAccessToken = resultt.access_token;
dynamic messagePost = new ExpandoObject();
messagePost.access_token = appAccessToken;
messagePost.picture = "";
messagePost.link = "";
messagePost.name = "[SOME_NAME]";
messagePost.caption = "{*actor*} " + "[YOUR_MESSAGE]"; //<---{*actor*} is the user (i.e.: Aaron)
messagePost.description = "[S开发者_如何学PythonOME_DESCRIPTION]";
FacebookClient appp = new FacebookClient(appAccessToken);
try
{
var result = appp.Post("/" + appId + "/feed", messagePost);
}
catch (FacebookOAuthException ex)
{
//handle something
}
catch (FacebookApiException ex)
{
//handle something else
}
or
var fb = new FacebookClient(appId, FacebookApplication.Current.AppSecret);
var appAccessToken = fb.AccessToken;
here is the code :
var fb = new FacebookOAuthClient(FacebookApplication.Current);
dynamic resultt = fb.GetApplicationAccessToken();
var appAccessToken = resultt.access_token;
dynamic messagePost = new ExpandoObject();
messagePost.access_token = appAccessToken;
messagePost.picture = "http://www.destination360.com/europe/sweden/images/s/sweden-visby.jpg";
messagePost.link = "http://www.destination360.com/europe/sweden/images/s/sweden-visby.jpg";
messagePost.name = "[SOME_NAME]";
messagePost.caption = "{*actor*} " + "[YOUR_MESSAGE]";
messagePost.description = "[SOME_DESCRIPTION]";
messagePost.from = AppId;
messagePost.to = "130736200342432";
FacebookClient appp = new FacebookClient(appAccessToken);
var result = appp.Post("/" + AppId + "/feed", messagePost);
精彩评论