Getting Events

Problem

I need to retrieve an event.

Solution

Use the Events.get() method, which allows you to filter for one user, a series of events, start/end times, and/or RSVP status. To filter for one user, specify null for the other filter parameters:

$events = $facebook->api_client->events_get(12345, null, null, null, null);

To retrieve one or more events, pass an array of event IDs (eids) as the second parameter:

$events = $facebook->api_client->events_get(null,
 array(14381739642,16044821668), null, null, null);

If you specify both a uid and an array of eids, Platform will return the events in the array that the user has on his list:

$events = $facebook->api_client->events_get(12345, array(14381739642,
16044821668), null, null, null);

You can add in a start and/or end time (in epoch seconds; see Formatting Relative Time for more info) to further filter the results:

$events = $facebook->api_client->events_get(12345, array(14381739642,
16044821668), 1209600000, 1214827199, null);

The final argument is to filter by a specific RSVP status, which are attending, unsure, declined, and not_replied:

$events = $facebook->api_client->events_get(12345, null, 1209600000,
 1214827199, 'declined');

Discussion

Events.get() will always return only those events that the current loggedinuser is allowed to see, regardless of who you specify as the uid filter (you’ll get an empty set of events back if the user isn’t allowed to see any of the events that should have been in the set).

The Client Library will ...

Get Facebook Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.