Facebook永久访问令牌PHP SDK

时间:2013-02-18 19:24:59

标签: php facebook sdk

随着最近Facebook的所有变化 - 重新:离线访问的折旧及其文档说长期存在的页面令牌现在是永久性的 - 我只是想确保我的代码实际上在我存储之前获得永久页面访问令牌它。 我希望你们先生们(和女士们)能够证实我的代码是正确的......

$facebook = new Facebook(array(
    'appId'  => APPID,
    'secret' => APPSECRET,
    'cookie' => true,
    'domain' => 'XXXXXXXX.com',
));
$user = $facebook->getUser();
if ($user) {
    try {
        $facebook->setExtendedAccessToken();
        $access_token = $facebook->getAccessToken();
        $user_profile = $facebook->api('/me');
        $_SESSION['user_token'] = $access_token;

        $page_info = $facebook->api("/".$_SESSION['PAGEID']."?fields=access_token");
        $_SESSION['page_token'] = $page_info['access_token'];
    } 
    catch (FacebookApiException $e) { 
        $username = "Unknown"; $user = "Unknown";    
    }
}

0 个答案:

没有答案