Facebook API Exception The remote server returned an error: (403) Forbidden
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;
Dictio开发者_如何学运维nary<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
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:
api.Post("/me/feed", postArgs);
Otherwise I suppose you need to add the access_token
to the postArgs.
for me this works really fine:
Facebook.FacebookAPI api = new Facebook.FacebookAPI("my token");
Dictionary<string, string> postArgs = new Dictionary<string, string>();
postArgs.Add("message","oki doki :D");
api.Post("/me/feed", postArgs);
hope it helps!
精彩评论