我正在使用以下代码(已在 Stackoverflow 上的某处发布)发布在 Facebook 页面的墙上。
它工作正常,但如果我没有登录,它会打开 Facebook 登录窗口。是否可以代表特定 Facebook 页面的管理员帐户执行代码?
protected void Page_Load(object sender, EventArgs e)
{
string app_id = "123410186463705";
string app_secret = "1234ecd9bea862197372de656eb3d7b";
// using Facebook SDK for .NET
var fb = new FacebookClient();
dynamic result = fb.Get( "oauth/access_token", new
{
client_id = app_id,
client_secret = app_secret,
grant_type = "client_credentials",
scope = "manage_pages,offline_access,publish_stream",
redirect_uri = Request.Url.AbsoluteUri
} );
var app_token = result.access_token;
var client = new FacebookClient(app_token);
dynamic parameters = new ExpandoObject();
parameters.message = "Check out this funny article";
parameters.link = "http://www.natiska.com/article.html";
parameters.picture = "http://www.natiska.com/dav.png";
parameters.name = "Article Title";
parameters.caption = "Caption for the link";
//446533181408238 is my fan page
client.Post("/446533181408238/feed", parameters);
}