javascriptfacebookfacebook-graph-apifacebook-page

post image or status with facebook page with api


since yesterday i try to post a status with image (or not) with a facebook page with facebook graph api.

client is connected with this scope :

email, public_profile, manage_pages, user_posts, publish_actions, publish_pages

i call this function

    postPicture = () => {
        FB.api("/231713458314438/feed",
                "POST", 
                {
                    "link": "http://ichef-1.bbci.co.uk/news/660/cpsprodpb/17A21/production/_85310869_85310700.jpg",
                    "message": "test"
                },
                function (response) {
                    console.log(response)
                }
        );
    }

publication is published but with my personnal account ON page and not in Admin with page.

So have you an idea to how published a status with page?


Solution

  • From the documentation here : https://developers.facebook.com/docs/graph-api/overview/

    You would also need to pass the access_token generated for the logged in admin as a paremeter request:

    postPicture = () => {
        FB.api("/231713458314438/feed",
                "POST", 
                {
                    "link": "http://ichef-1.bbci.co.uk/news/660/cpsprodpb/17A21/production/_85310869_85310700.jpg",
                    "message": "test",
                    "access_token": {your-access-token}
                },
                function (response) {
                    console.log(response)
                }
        );
    }