为Facebook生成“永不过期”的访问令牌

时间:2015-05-13 20:48:02

标签: php

我有这个错误 “(OAuthException - #190)验证访问令牌时出错:会话无效

如何生成永不过期的访问令牌?

我使用此代码:

<?php
    require 'facebook.php';
    $facebook = new Facebook(array(
        'appId' => ' ',
        'secret' => ' ',
        'cookie' => true
    ));
    $fbPageID = $_GET['url'];
    $token = " ";
    $facebook->setAccessToken($token);
    $user = $facebook->getUser();
    if($user){
        $json = file_get_contents('https://graph.facebook.com/' . $fbPageID . '/subscribers?access_token='.$token);
        $data = json_decode($json);
        echo  $data->summary->total_count;
    }else{
        echo "token non valido.";
        /*
        $loginUrl = $facebook->getLoginUrl()."&scope=offline_access,manage_pages";
        header("location:".$loginurl);
        exit();
        */
    }
    ?>

谢谢!

0 个答案:

没有答案