Facebook Graph API - How to post to a page?

1

Good afternoon. I need to know how to adapt the script below so that I make the post on the page that the logged in user is an administrator. For example, if my user admin is 3 pages in the face, I want to post directly through the page and not as if my user had made the post on the page.

FB.login(function () {
                FB.api('/page-id?fields=access_token', 'GET', function (response) {

                    FB.api('/' + response.id + '/photos', 'POST', { message: mensagem, url: imagem }, function (response) {
                        if (!response || response.error) {
                            console.log(response);
                            alert('Error occured');
                        } else {
                            alert('Post ID: ' + response.id);
                        }
                        $("#post-face-action").modal('hide');
                    });

                });

            }, { scope: 'publish_actions, publish_pages, manage_pages' });
    
asked by anonymous 19.05.2017 / 19:43

1 answer

0

You must have the permissions:

The id page and access token are requirements. Not tested, but I believe it's important to get the page access token to use in the post , not the user.

Credits

    
19.05.2017 / 20:33