Question

I am using visual studio 2013 .NET 4.5 and C# with a windows forms client application, I am trying to post a message to my own Facebook managed page. I have created a new Facebook application, but not yet published it, I am unsure of the settings, but I have the app_id, app_secret and from debugging I have the access_token.

I used a piece of code to open a browser window to login with permissions and this was successful/

I am getting the following error:

OAuthException - #200) (#200) The user hasn't authorized the application to perform this action

The code I am using is below:

var fb = new FacebookClient("AUTH_CODE")
dynamic parameters = new ExpandoObject();
parameters.message = "hello tweet tweet";
dynamic result = fb.Post("SITE_ID/feed", parameters);
var id = result.id;

for logging in I am using:

var client = new FacebookClient();
client.AppSecret = app_secret;
client.AppId = app_id;
client.AccessToken = "AUTH_CODE";

var fbLoginUri = client.GetLoginUrl(new
{
     client_id = app_id,
     redirect_uri =
     "https://www.facebook.com/connect/login_success.html",
     response_type = "code",
     scope = "manage_pages,offline_access,publish_stream,publish_actions"
});
 System.Diagnostics.Process.Start(url);

I am already logged in and the message on the browser shows SUCCESS...

The DLL that I have referenced is the latest v6.0 Facebook C# SDK

Do I need to setup the Facebook app so that it has permissions to post onto my managed wall and if so how do I do it.

I hope someone out there can help, I have been looking at this for days and I need a little help.

PS:

I have also tried the following code:

        var fb = new FacebookClient();
        dynamic result = fb.Get("oauth/access_token", new
        {
            client_id = app_id,
            client_secret = app_secret,
            grant_type = "client_credentials",
            scope = "manage_pages,offline_access,publish_stream"
        });

        var app_token = result.access_token;

        var client = new FacebookClient(app_token);

        dynamic parameters = new ExpandoObject();
        parameters.message = "Check out this funny article";
        parameters.link = "http://www.natiska.com/article.html";
        parameters.picture = "http://www.natiska.com/dav.png";
        parameters.name = "Article Title";
        parameters.caption = "Caption for the link";

        //446533181408238 is my fan page
        client.Post("/446533181408238/feed", parameters);

Paul.

Was it helpful?

Solution

It seems that the request code from your access token request is missing which probably causes this error, see this question for more details on this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top