我有以下代码:
private void CheckAuthorization()
{
string app_id = "x";
string app_secret = "x";
string scope = "publish_stream,publish_actions";
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 = WebRequest.Create(url) as HttpWebRequest;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
string vals = reader.ReadToEnd();
foreach (string token in vals.Split('&'))
{
//meh.aspx?token1=steve&token2=jake&...
tokens.Add(token.Substring(0, token.IndexOf("=")),
token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
}
}
string access_token = tokens["access_token"];
var client = new FacebookClient(access_token);
//client.Post("/me/feed", new { message = "A simple test" });
var args = new Dictionary<string, object>();
args["message"] = "abc";
args["caption"] = "This is caption!";
args["description"] = "This is description!";
args["name"] = "This is name!";
args["picture"] = "picutre";
args["link"] = "http://www.bradspel.net/";
client.Post("/1418771281723422/feed", args);
}
}
发帖时我得到这个:
(OAuthException - #200) (#200) Insufficient permission to post to target on behalf of the viewer
如果我将 client.post 更改为:
client.Post("/me/feed", args);
它工作得很好。
那么,当我要发布到特定的墙上时,为什么这不起作用?我已经在这个facebook页面上设置了允许所有人发帖的权限。 Facebook 应用程序设置为在线。
最佳答案
通过创建扩展页面 token 并使用它来使帖子一切正常。看到这个:How to get Page Access Token by code?
令我惊讶的是,这个简单的任务执行起来如此困难,而且几乎没有什么帮助。
关于c# - 没有足够的权限代表查看者发布目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25361366/