Facebook: oautheexception:(#200)必须有一个有效的access_token来访问这个端点


Facebook: OAuthException: (#200) Must have a valid access_token to access this endpoint

我试图从facebook获取所有公共事件,

当我尝试执行我的php代码从我的服务器我得到错误:Uncaught oauthexcexception:(#200)必须有一个有效的access_token访问这个端点抛出/....../sdk/src/base_facebook.php在1254

而如果我在heroku上执行相同的代码…它的工作原理……我想在我的服务器....上执行代码请帮助……我的代码是…:

    <?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");
}

可能和这个

有关

Facebook bug