Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook SDK 4 for PHP-无需登录获取某些事件_Php_Facebook_Facebook Graph Api_Facebook Php Sdk_Facebook Sdk 4.0 - Fatal编程技术网

Facebook SDK 4 for PHP-无需登录获取某些事件

Facebook SDK 4 for PHP-无需登录获取某些事件,php,facebook,facebook-graph-api,facebook-php-sdk,facebook-sdk-4.0,Php,Facebook,Facebook Graph Api,Facebook Php Sdk,Facebook Sdk 4.0,我尝试使用Facebook SDK 4 for PHP 但有一件事我不明白:将它与应用程序访问令牌一起使用 我尝试了不同的令牌来初始化FaceBookSession,但我不明白它是如何工作的…:/ 例如,使用此示例代码: $request = new FacebookRequest( $session, '/480602392011337/events?fields=id,end_time,description,is_date_only,location,name,start_time

我尝试使用Facebook SDK 4 for PHP

但有一件事我不明白:将它与应用程序访问令牌一起使用

我尝试了不同的令牌来初始化FaceBookSession,但我不明白它是如何工作的…:/

例如,使用此示例代码:

$request = new FacebookRequest(
  $session,
  '/480602392011337/events?fields=id,end_time,description,is_date_only,location,name,start_time&since='.date('Y-m-d',strtotime('-1 year')).'&until='.date('Y-m-d',strtotime('+1 year')).'&limit=500',
  //'/480602392011337/events',
  'GET'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();

谢谢你的帮助!:)

我终于找到了解决方案(thx-Google),只需使用
FacebookSession::newAppSession()


我不知道如何拥有有效的访问令牌。。。使用此命令:
$session=newfacebooksession('xxxxxxxxx')感谢您提示调用过去的事件。我从未收到过任何事件,直到我意识到只有过去的事件(
// init app with app id (APPID) and secret (SECRET)
FacebookSession::setDefaultApplication('xxxxxx','xxxxxxx');
//  Get the access token for this app
$session = FacebookSession::newAppSession();

// make the API call, $datas contains the events for the facebook fan page BDE Polytech Marseille
try {
$request = new FacebookRequest(
    $session,
    'GET',
    '/{page-id}/events?fields=id,end_time,description,is_date_only,location,name,start_time&since='.strtotime('-1 year').'&until='.strtotime('+1 year').'&limit=500'
);
$response = $request->execute();

$datas = $response->getGraphObject()->asArray();

}catch (FacebookRequestException $e) {
    echo $e->getMessage();
}catch (\Exception $e) {
    echo $e->getMessage();
}