编辑(2012年8月14日):
一周前,官方的Facebook PHP SDK更新了。函数名称已更改为 setExtendedAccessToken,并且决定我们实际上需要在之后销毁会话,以消除具有两个活动会话的风险。
此外,该函数不再实际返回令牌,而是将其存储在持久化数据中。因此,您可以在之后使用公共函数getAccessToken获取新的访问令牌。从官方Facebook PHP SDK github页面获取新的SDK,以确保您是最新的。
原始答案:
我已将新的公共函数添加到base_facebook.php文件中,该函数返回一个新的访问令牌,该令牌将在 60 天后过期。您可以在收到正常访问令牌后向此函数发出请求。我还没有测试过,但我认为您还需要在开发者应用的高级设置中启用“弃用offline_access”。
只需将其添加到facebook类中的base_facebook.php中,然后对其进行调用即可。它对我有用。
 public function getExtendedAccessToken(){
    try {
        // need to circumvent json_decode by calling _oauthRequest
          // directly, since response isn't JSON format.
        $access_token_response =
            $this->_oauthRequest(
                $this->getUrl('graph', '/oauth/access_token'), array(
                    'client_id' => $this->getAppId(),
                    'client_secret' => $this->getAppSecret(),
                    'grant_type'=>'fb_exchange_token',
                    'fb_exchange_token'=>$this->getAccessToken()
                )
            );
    } catch (FacebookApiException $e) {
      // most likely that user very recently revoked authorization.
      // In any event, we don't have an access token, so say so.
      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'];
}