1
Vote

error-"The user hasn't authorized the application to perform this action" while posting on page

description

Hi All,
 
Using facebooktoolkit i am able to post on the user's wall. But i am not able to post on the page which is administered by that user.
 
My code is as below-
Facebook.Session.ConnectSession connectsession = new Facebook.Session.ConnectSession(APIKey, AppSecret);
        Facebook.Rest.Api api = new Facebook.Rest.Api(connectsession);

        api.Session.SessionKey = Auth_token;
        api.Session.UserId = UserId;
 
        Facebook.Rest.attachment_media_image myimage = new Facebook.Rest.attachment_media_image();
        //href is the link for the image if you click on it
        myimage.href = "http://testpage.com";
        myimage.src = "http://testpage.com/image.png";
        List<Facebook.Rest.attachment_media> mymedia = new List<Facebook.Rest.attachment_media>();
        mymedia.Add(myimage);
 
        Facebook.Rest.attachment myattachment = new Facebook.Rest.attachment();
 
        //name is bold heading for entry, to right of image
        myattachment.name = "Title of your post by testpage.com";
        //href is the link target for the 'name'
        myattachment.href = "http://testpage.com";
 
        //caption is the long article text below the name
        myattachment.caption = "Here is the main message for the wall/stream post";
 
        //description appears under image
        myattachment.description = "Something to describe the image";
 
        myattachment.media = mymedia;
 
        IList<Facebook.Schema.action_link> myactionlinks = new List<Facebook.Schema.action_link>();
        Facebook.Schema.action_link myactionlink = new Facebook.Schema.action_link();
        myactionlink.href = "http://testpage.com";
        myactionlink.text = "Description for hyperlink";
        myactionlinks.Add(myactionlink);
 
        //my page
        api.Stream.Publish("", myattachment, myactionlinks, "", UserId); //throws error
 
I have generated the access token for user(with manage_pages,offline_access,publish_stream extended permissions) and based on that access token, i am making the accounts connection (https://graph.facebook.com/me/accounts?access_token=<user_access_token>) to get the access token for the user administered page on facebook. this call successfully returns me the access token for that page.
Now i am using the same code and the access token returned from accounts connection to post the message on that page's wall.
But api.stream.publish call throws error - "The user hasn't authorized the application to perform this action"
I need to get this error resolved as soon as possible for my client, So can anyone please help me out?
 
Thanks
Alpesh

comments

alpsds1980 wrote Jan 3, 2011 at 7:08 PM

Hi All,

Is there anyone who can help me resolve this issue ? I am really stuck and not able to find a fix to this issue.
Any help will be highly appreciated.

Thanks
Alpesh

ntotten wrote Jan 7, 2011 at 7:15 PM

I would recommend switching to the Facebook C# SDK (http://facebooksdk.codeplex.com). As you may have seen, this project has been discontinued. http://facebooktoolkit.codeplex.com/

nouka wrote May 29, 2011 at 7:39 PM

have u manged to solve this.
I'm having the same problem even from the test console :(

wrote Feb 21, 2013 at 11:37 PM