Facebook API 异常远程服务器返回错误:(403) Forbidden
我正在尝试使用以下代码在 Facebook 墙上发布消息(Facebook C# SDK - http://facebooksdk.codeplex。 com/)
Facebook.FacebookAPI api = new Facebook.FacebookAPI("my token");
JSONObject me = api.Get("/me");
var userId = me.Dictionary["id"].String;
Dictionary<string, string> postArgs = new Dictionary<string, string>();
postArgs["message"] = "Hello, world!";
api.Post("/" + userId + "/feed", postArgs);
我能够提取用户个人资料信息,但在发布消息时抛出 错误消息如下。
远程服务器返回错误:(403) 禁止。 描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:Facebook.FacebookAPIException:远程服务器返回错误:(403) 禁止。
可能是什么问题?
任何帮助将不胜感激
谢谢 迪普
I am trying to use the following code to post a message on facebook wall (Facebook C# SDK - http://facebooksdk.codeplex.com/)
Facebook.FacebookAPI api = new Facebook.FacebookAPI("my token");
JSONObject me = api.Get("/me");
var userId = me.Dictionary["id"].String;
Dictionary<string, string> postArgs = new Dictionary<string, string>();
postArgs["message"] = "Hello, world!";
api.Post("/" + userId + "/feed", postArgs);
I am able to pull the user profile information but while posting a message throwing an
error message like below.
The remote server returned an error: (403) Forbidden.
Description: An unhanded exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Facebook.FacebookAPIException: The remote server returned an error: (403) Forbidden.
What could be the issue ?
Any help would be appreciated
Thanks
Deepu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,确保您拥有publish_stream 许可!
我不是 C# 专家,但如果用户已经连接,则无需提取用户 ID 来发布到他的个人资料:
否则我想您需要将
access_token
添加到 postArgs。First of all, make sure that you have the publish_stream permission!
I'm no expert in C#, but no need to extract the user id to post to his profile if the user is already connected:
Otherwise I suppose you need to add the
access_token
to the postArgs.对我来说这真的很好:
希望它有帮助!
for me this works really fine:
hope it helps!