2
因为我们知道Offline_access已被弃用,现在有人可以告诉我,如果没有这种权限,我们如何才能获得长期存取的令牌?如何扩展访问令牌有效性?
因为我们知道Offline_access已被弃用,现在有人可以告诉我,如果没有这种权限,我们如何才能获得长期存取的令牌?如何扩展访问令牌有效性?
您可以通过将以下函数添加到base_facebook.php来扩展访问令牌。
//扩展令牌值的函数。
公共职能getExtendedAccessToken(){
try {
$access_token_response =
$this->_oauthRequest(
$this->getUrl('graph', '/oauth/access_token'),
$params = array( 'client_id' => $this->getAppId(),
'client_secret' => $this->getApiSecret(),
'grant_type'=>'fb_exchange_token',
'fb_exchange_token'=>$this->getAccessToken(),
));
} catch (FacebookApiException $e) {
return false;
}
if (empty($access_token_response)) {
return false;
}
$response_params = array();
parse_str($access_token_response, $response_params);
if (!isset($response_params['access_token'])) {
return false;
}
return $response_params['access_token'];
}
检查:http://stackoverflow.com/a/9712663/122978 – greut 2012-04-20 13:26:12