我正在构建一个控制台应用程序,它将将流发布到页面墙上。
问题:我收到“用户尚未授权应用程序执行此操作”。我正在使用 opengraph 来获取访问令牌。
我错过了什么吗?任何帮助是极大的赞赏。谢谢!
// constants
string apiKey = "XXX";
string secret = "XXX";
string pageId = "XXX";
// get access token
string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&client_secret={1}&grant_type=client_credentials", apiKey, secret); // todo: figure out open graph url
WebRequest req = WebRequest.Create(url);
WebResponse resp = req.GetResponse();
StreamReader reader = new StreamReader(resp.GetResponseStream());
string respStr = reader.ReadToEnd();
string accessToken = respStr.Replace("access_token=", "");
// construct the post
dynamic messagePost = new ExpandoObject();
messagePost.access_token = accessToken;
messagePost.picture = "www.google.com/pic.png";
messagePost.link = "www.google.com";
messagePost.name = "some name";
messagePost.captiion = "some caption";
messagePost.description = "some description";
messagePost.req_perms = "publish_stream";
messagePost.scope = "publish_stream";
// using client
FacebookClient client = new FacebookClient(accessToken);
try // to post the post to the page's wall
{
var result = client.Post(string.Format("/{0}/feed", pageId), messagePost);
}
catch (FacebookOAuthException ex)
{
// getting caught here, with error msg = "The user hasn't authorized the application to perform this action"
}
catch (FacebookApiException ex)
{
// ignore
}
访问以下链接后,我能够运行代码并将其成功发布到页面墙上,之后它会显示在喜欢者的新闻提要中。
http://www.facebook.com/login.php?api_key= http://www.facebook.com/login.php?api_key={API_KEY_GOES_HERE}&next=
http://www.facebook.com/connect/prompt_permissions.php?api_key= http://www.facebook.com/connect/prompt_permissions.php?api_key={API_KEY_GOES_HERE}&next={PAGE_ID_GOES_HERE}
感谢 上的回答授权 Facebook 粉丝页面进行状态更新 https://stackoverflow.com/questions/2097665/authorizing-a-facebook-fan-page-for-status-updates
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)