How to handle expired access token in facebook graph api
I am working on web application in which I have implemented Facebook connectivity. User can post to his/her Facebook wall from my site.
I know that access token is required for updating user's status from my site & access token expires after certain amount of time i.e after 2 hrs.
So if user's access token expires user needs to be re-authenticated with Facebook to be able to post on wall. But i want to implement it something like twitter does. Once you connect your Facebook account to Twitter your tweets are posted to Facebook.
I have read this, but I don't understand PHP. Can I renew the token? If yes开发者_如何学运维 then how? And how twitter implements it? Please guide me I am new to this stuff.
Thanks in advance...!
the offline_access permission is valid forever or until the user explicitly deauthenticates your app in their facebook application settings. The way that I check for this in my app is by the following:
@$accounts = json_decode(file_get_contents("https://graph.facebook.com/".$fb_info['uid']."/accounts?access_token=".$fb_info['access_token']));
if($accounts){
$deauthed=false;
}
now reprompt for permissions for a new access token
you cant renew the access token. But you can request the offline_access extended permission. When your app has this permission you receive an access_token
that is long-lived.
I seem to remember reading somewhere that it is valid for 30 days... but Im not 100% sure on that figure..
精彩评论