Rakesh
Rakesh

Reputation: 92

(OAuthException) (#200) exception while posting to facebook wall using facebook c#sdk

i am working on asp.net mvc3 and i am using facebook c# sdk to post on fb wall . i get following error while trying to post on wall.

(OAuthException) (#200) The user has not granted the application the permission to automatically publish feed stories

please see the code i used .

string appAccessToken = "accessstoken"; //this token i got after creatting app in fb developer.

        FacebookClient fb = new FacebookClient(appAccessToken);
        Dictionary<string, object> parameters = new Dictionary<string, object>()
                                                    {
                                                        {"description", "Testbeskrivning"},
                                                        {"link", ""},
                                                        {"name", "Testtitel" }

                                                    };

        fb.Post("myfbid/feed", parameters);

Upvotes: 0

Views: 1866

Answers (1)

Kevin Cloet
Kevin Cloet

Reputation: 2976

That's because you haven't added the right permission when you get the LoginUrl: You will have to add the following permission: publish_stream.

var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
oAuthClient.RedirectUri = new Uri(redirectUrl);

Dictionary<String, Object> oParams = new Dictionary<String, Object>();
oParams.Add("scope", "publish_stream");

var loginUri = oAuthClient.GetLoginUrl(oParams);

For the most Facebook features you need the permissions from the users. Check the following page for all the current permissions:

https://developers.facebook.com/docs/reference/api/permissions/

Upvotes: 1

Related Questions