emotionull
emotionull

Reputation: 615

Facebook access tokens, permissions and offline publish_actions

I am working on an app where one of the things that I want to do is publish a status on behalf of a user, offline. That is when the user is not using the app. The facebook's documentation is not clear about validity of access tokens, type of access token required for particular call(like publish stream), how to renew it, etc. I am using PHP Facebook SDK. It has a function setExtendedAccessToken(). But it is for extending the short-lived access token obtained by the client side for 60days(with some exception cases ofcourse). What if I have a long-lived access token that I obtained via server-to-server call. More specifically, by calling the $facebook->getAccessToken() method. I am using the following code to post in offline mode.

$req =  array(
'access_token' => $access_token, //stored in db, obtained thru getAccessToken()
'name' => "Awesome Status!",
'link' => "apps.facebook.com/myapp",
'description' => "Some Description",
'picture'=>"xxx.jpg",
'caption' => "Caption this"
);
$res = $facebook->api("/$userid/feed", 'POST', $req);

Thanks!

Addition:

Tried using setExtendedAccessToken function, but it doesn't change anything. I even checked the access tokens information here. I think it works for with the short-lived, client side generated token.

Upvotes: 1

Views: 1531

Answers (1)

Sahil Mittal
Sahil Mittal

Reputation: 20753

You can use the App Access Token (APP_ID|APP_SECRET) to publish on behalf of the user offline; once the user has authorized your app.

Upvotes: 3

Related Questions