cars
cars

Reputation: 441

Facebook Graph to show Event Attendees

I am looking to display the attendees for a given facebook event on a PHP page. Ideally it would be that graphical display with people's pictures displaying.

I believe this could be done using the facebook graph API, but the following is giving me an error requiring signature:

https://api.facebook.com/method/fql.query?query=SELECT uid FROM event_member WHERE eid =  ... AND rsvp_status = 'attending'

Also, how would I even get the eid? Can it simply be parsed off the end of an event page link? www.facebook.com/events/...eid#...

Thanks everybody!

Upvotes: 1

Views: 4033

Answers (1)

Juicy Scripter
Juicy Scripter

Reputation: 25918

To get event attendees you can run following FQL query:

SELECT uid FROM event_member WHERE eid = "EXISTING_EVENT_ID"

Event id is something you can get from many sources, if you create event via Graph API you'll get event id as response. Or you can get ids of events current/specific user attending. Or as you already noted from URL of event page.

Next FQL query will return all events current user is attending:

SELECT eid FROM event_member WHERE uid = me() AND rsvp_status = "attending"

Queries can be nested so you can do stuff like get list of all attendees of all events current user ever attended:

SELECT eid, uid FROM event_member WHERE eid IN (
  SELECT eid FROM event_member WHERE uid = me() AND rsvp_status = "attending"
)

To get details of attendees for specific event something like this may do the work:

SELECT uid, name, pic_square FROM user WHERE uid IN (
  SELECT uid FROM event_member WHERE eid = "EXISTING_EVENT_ID"
)

NOTES:

  • You'll need any valid access_token to get public events details.
  • To retrieve events of current user you'll need user_events permission to be granted to your application by this user.
  • You can display user image with only knowing his id with URL in format of http://graph.facebook.com/{USER_ID}/picture
  • You can run FQL queries with Graph API by issuing GET request to https://graph.facebook.com/fql?q={QUERY_HERE}

For more details on FQL and Graph API read documentation, especially on tables event_member and user

Upvotes: 7

Related Questions