O'Reilly logo

Facebook Cookbook by Jay Goldman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required