Facebook:OAuthException:(#200)必须具有有效的access_token才能访问此端点

时间:2013-04-15 12:00:49

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

我正在尝试从facebook上获取所有公共活动,

当我尝试从我的服务器执行我的PHP代码时,我收到错误:未捕获OAuthException:(#200)必须有一个有效的access_token才能访问/....../sdk/中抛出的此端点第1254行的src / base_facebook.php

如果我在heroku上执行相同的代码......它可以工作....我想在我的服务器上执行代码.... plz help ....我的代码是..:

    <?php

require_once('utils.php');

require_once('sdk/src/facebook.php');

$facebook = new Facebook(array(
  'appId'  => '.........',
  'secret' => '..............',
  'sharedSession' => true,
  'trustForwarded' => true,
));

$events =idx($facebook->api('/search?q=trade&type=event&limit=5000&access_token=ksdkslhosihgksjdhlshfshdfgskdjhsklfhsklfhskfjhsdlkhslhslh'), 'data', array());

$var=1;

foreach($events as $event)
{

    $id = idx($event, 'id');
    $name = idx($event, 'name');
    $owner = idx($event, 'owner');
    $start_time = idx($event, 'start_time');
    $end_time = idx($event, 'end_time');
    $location = idx($event, 'location');
    $description = idx($event, 'description');
     echo "S.No:".$var."<br>";
     echo "ID:".he($id)."<br>";
     echo "Name:".he($name)."<br>";
     echo "Owner:".he($owner)."<br>";
     echo "start_time:".he($start_time)."<br>";
     echo "end_time:".he($end_time)."<br>";
     echo "location:".he($location)."<br>";
     echo "description:".he($description)."<br>";
     $var=$var+1;
}   

?>

使用的util.php文件与heroku相同.....

util.php

    <?php

/**
 * @return the value at $index in $array or $default if $index is not set.
 */
function idx(array $array, $key, $default = null) {
  return array_key_exists($key, $array) ? $array[$key] : $default;
}

function he($str) {
  return htmlentities($str, ENT_QUOTES, "UTF-8");
}

1 个答案:

答案 0 :(得分:-1)

可能与此相关

Facebook bug