facebook-php-sdk列出我的fb页面管理员可以在localhost上运行,而不是在生产上

时间:2014-02-18 12:35:03

标签: php facebook facebook-graph-api facebook-php-sdk

下面的代码在我的本地计算机上按预期运行,但在我的生产中抛出以下错误:

  

致命错误:未捕获OAuthException:必须是活动访问令牌   用于查询有关当前用户的信息。

我已经仔细检查了我的配置和页面权限,但找不到原因。

   require 'facebook-php-sdk/src/facebook.php';
    $path               = $_SERVER['DOCUMENT_ROOT'].'/../conf/' . php_uname('n'). '.ini';
    $iniConfig          = parse_ini_file($path, true);
    $page_id            = $iniConfig['fb_theclient']['page_id'];

    $facebook = new Facebook(array(
        'appId'     => $iniConfig['fb_theclient']['appId'],
        'secret'    => $iniConfig['fb_theclient']['secret']
    ));

    $user               = $facebook->getUser();
    $page_info          = $facebook->api('/'.$page_id.'?fields=access_token');

     if( !empty($page_info['access_token']) ) {  # if we have access_token,
         $args = array(
             'access_token'  => $page_info['access_token'],
             'scope'         => 'publish_stream, manage_pages'
         );
     }
         # Get our admins info
        $a_admins  = $facebook->api('/' . $page_id .'/admins', 'get', $args);

        foreach($a_admins['data'] as $thisadmin){
            $myadmin[] = array('name' => $thisadmin['name'], 'id '=> $thisadmin['id']);
        }

    print_a($myadmin);

function print_a($arr){

    echo "<PRE>";
    print_r($arr);
    echo "</PRE>";

}

0 个答案:

没有答案