vctlzac
vctlzac

Reputation: 847

Posting in wall with not logged user (using offline token)

I need to post on the wall of a user as if it were itself (offline token), but when logged in with another user. Example:

I login with user X. In some moment I want to post on the wall of the user Y as if he had posted (using offline token).

Ps: I do not want this:

        var wallPost = {
            message : " My message",
    };
    FB.api('/USER_ID/feed', 'post', wallPost , function(response) {
        if (!response || response.error) {
            console.log("facebook error: " + response.error);
        }
    });

I need the post is in "FB.api ('/ME/feed', 'post', wallPost, function (response) {"

But this "ME" is not the logged user, but the user owns of the offline token.

Upvotes: 0

Views: 1236

Answers (2)

vctlzac
vctlzac

Reputation: 847

SOLUTION:

Just insert the acess_token in JSON parameter.

   var wallPost = {
        message : " My message",
        access_token : "ACCESS_TOKEN_OFF_LINE_OF_THE_USER"
};
FB.api('/me/feed', 'post', wallPost , function(response) {
    if (!response || response.error) {
        console.log("facebook error: " + response.error);
    }
});

Upvotes: 1

DMCS
DMCS

Reputation: 31870

You cannot do that with the Javascript API because the FB.api call will only use the access token for the currently logged in user. You will need to build a call directly to HTTP post the message to the https://graph.facebook.com/me/feed?access_token={the offline access token you have}

Upvotes: 1

Related Questions