Facebook Restful PHP Client - get Events of a User

2019-09-07 01:29发布

问题:

im using the Facebook PHP Client library and want to get the Events of a user without first logging in as a user.

Is that possible?

I got the User ID and the events.get method has a parameter UID.

<?php
//  Configure
$apiKey     = 'xxx';
$secretKey  = 'xxx';

// Include Lib
require_once('facebook.php');

// init main object
$facebook = new Facebook($apiKey,$secretKey);
$events = $facebook->api_client->events_get(123456);
?>

so this piece of code does not work. if i first require a login of a certain user, i get my results. isnt it possible to get events of a user without logging in?

回答1:

According to the Facebook API Docs for Events.get

http://wiki.developers.facebook.com/index.php/Events.get

This method no longer requires a session key. However if you call this method without an active user session, you can only get the events for which your application was the creator; you can see only those event attendees who authorized your application. Applications can create events for users if the users grant the application the create_event extended permission.

Basically, the user has to be logged in otherwise you can only see events in which your app created.