我正在尝试使用Facebook Graph API发布我的Facebook粉丝页面。为此,我使用扩展页面访问令牌。我能够在Facebook上发布我的内容,但是当我从管理员帐户注销并尝试在我的粉丝页面上发布内容时,我收到此错误。请指导我如何解决此问题?
要获取扩展页面访问令牌,我已按照这些流程进行操作 -
CS代码 -
protected void Page_Load(object sender, EventArgs e)
{
CheckAuthorization();
}
private void CheckAuthorization()
{
string app_id = "XXXXXX";
string app_secret = "XXXXX";
//string my_url = "http://localhost:6943/ashish/Default2.aspx";
string scope = "publish_stream, publish_actions, manage_pages, email,user_location,user_birthday";
if (Request["code"] == null)
{
Response.Redirect(string.Format("https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}", app_id, Request.Url.AbsoluteUri, scope));
}
else
{
Dictionary<string, string> tokens = new Dictionary<string, string>();
string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}", app_id, Request.Url.AbsoluteUri, scope, Request["code"].ToString(), app_secret);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string vals = reader.ReadToEnd();
foreach (string token in vals.Split('&'))
{
tokens.Add(token.Substring(0, token.IndexOf("=")),
token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
}
string access_token = "Long Lived Access Token";
var client = new FacebookClient(access_token);
dynamic parameters = new ExpandoObject();
parameters.message = "xxxxxxxxxxxxxxxxxxxxxxxx";
parameters.link = "XXXXXXXXXXXX";
parameters.picture = "XXXXXXXXXXXXXXXXX";
parameters.name = "XXXXXXXXXXXXXXX";
parameters.caption = "XXXXXXXXXXX";
client.Post("/FB Fan page ID/feed", parameters);
}
}
答案 0 :(得分:0)
收到此错误时,您应重新初始化身份验证过程。这是出于安全原因;注销时,所有相关的访问令牌(可以)重置。
如果没有管理员的互动,您无法解决此问题。因此,处理此问题的方法是捕捉这种情况并将用户引导到应用程序中的身份验证部分。