Has Facebook graph API stopped return expires when exchanging for long-lived tokens? -
i'm using facebook php sdk obtain user's access token. code copied here https://developers.facebook.com/docs/php/gettingstarted/4.0.0 should below:
$helper = new facebookredirectloginhelper('your redirect url here'); $loginurl = $helper->getloginurl(); // use login url on link or button redirect facebook authentication
and in redirect action:
$helper = new facebookredirectloginhelper(); try { $session = $helper->getsessionfromredirect(); var_dump($session); } catch(facebookrequestexception $ex) { // when facebook returns error } catch(\exception $ex) { // when validation fails or other local issues }
a couple of weeks ago, see expires value returned api. now, access_token returned. has facebook changed api output?
the above code looks fine for,
token expiration sol : facebook has changed endpoint redirect url long live tokens,
now end point : https://graph.facebook.com/oauth/client_code?access_token=...&client_secret=...&redirect_uri=...&client_id=...
also facebook bydefault provides short live access tokens expires in 2hours if want long live token access has life 60days can use following function. link ref
$longlivedsession = $facebooksession->getlonglivedsession();
echo $longlivedsession->gettoken();
check following links highlights more information related long live tokens. https://developers.facebook.com/docs/facebook-login/access-tokens#extending
Comments
Post a Comment