Mohit
Mohit

Reputation: 75

Facebook Post through Graph API with access token

I am developing a facebook app where I need impersonation of users, so there is an option when you use facebook for "Use Facebook As", i need to implement the same in my app.

I see the access tokens retrieved for the pages I own, but I don't understand how to use this with the following graph api to post

var body = 'Reading JS SDK documentation';
      FB.api('/me/feed', 'post', { message: body }, function (response) {
         if (!response || response.error) {
            alert('Error occured');
        } else {
            alert('Post ID: ' + response.id);
        }
    });

so my question is how do I set the access token for the api in this case??

I Hope, am clear with my question

Upvotes: 0

Views: 285

Answers (1)

Andy Jones
Andy Jones

Reputation: 6275

Add it with the parameters. Change this line

FB.api('/me/feed', 'post', { message: body }, function (response) {

to...

var my_token = "the access token value";
FB.api('/me/feed', 'post', { message: body, access_token : my_token }, function (response) {

Upvotes: 1

Related Questions