Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a list of events owned by a facebook page

Tags:

facebook

Does anyone know how I can get a list of events owned (created) by a Facebook page?

I seem to be able to use the "graph api" to generate a list of the events an entity is attending. I also looked at FQL, but it seems to require that the 'where' clause is an indexable field (and, naturally, the id is the only indexable field).

For bonus points, we'd be able to do this without any authentication. (Though I'm resigned to the fact that I'm likely going to need at least a permanent access_token.)

If anyone knows how to do this I'd be eternally grateful.

like image 887
Tom Wright Avatar asked May 25 '10 17:05

Tom Wright


3 Answers

All FQL data access requires authentication, so forget about those "bonus points".

This is going to require some post-query handling as, like you said, the FQL WHERE clause only respects indexible fields and the owner.id field is not indexible. Thus, we first begin by identifying events the user is a "member" of and loading the owner information for those events.

SELECT id, name, owner.id FROM event WHERE id IN (SELECT eid FROM event_member WHERE uid = XXX)

Once the query returns a dataset, we must manually check for rows in which owner.id is equal to uid.

like image 55
defines Avatar answered Nov 09 '22 00:11

defines


Looks like you have to first query the event_member table, using the uid

http://developers.facebook.com/docs/reference/fql/event_member

and then once you got the eid of the events you can query the events table where the eid is indexed http://developers.facebook.com/docs/reference/fql/event

and I'm sure you can use the first as a subquery of the second query like var query = FB.Data.query("select name from event where eid in (select eid from event_member where uid = {0})", user_id);

like image 35
hndcrftd Avatar answered Nov 08 '22 23:11

hndcrftd


This one does it

select eid from event where creator=".$facebookPageId." and eid in (select eid from event_member where uid=".$facebookPageId.") ORDER BY start_time DESC

like image 1
Sune Avatar answered Nov 08 '22 23:11

Sune