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>();
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";
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?