facebook c#sdk – 用户尚未授权应用程序执行此操作

我正在构建一个控制台应用程序,它将流发布到页面的墙上。

问题:我收到“用户未授权应用程序执行此操作”。 我正在使用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 } 

在访问以下链接后,我能够运行代码并将其成功发布到页面的墙上,然后显示在Likers的新闻源中。

http://www.facebook.com/login.php?api_key= {API_KEY_GOES_HERE}&next = http://www.facebook.com/connect/login_success.html&req_perms=read_stream,publish_stream

http://www.facebook.com/connect/prompt_permissions.php?api_key= {API_KEY_GOES_HERE}&next = http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&display=popup&ext_perm=publish_stream&profile_selector_ids= {PAGE_ID_GOES_HERE}

感谢有关授权Facebook粉丝页面进行状态更新的答案

“喜欢你的申请”和“允许你的申请发布到他的墙上”是两个不同的句子。 没有魔杖可以让你覆盖用户的喜好,无论他们喜欢与否。

你最好的办法是处理“失败”并继续下一个人。 如果你想了解那些不希望你发布到他们墙上的人,你可以在回复中获得这些信息并将其存储在某种类型的“日志”中。