tags:

views:

143

answers:

3

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.

+1  A: 

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);

Raine
Can you get it to work? I get errors because uid isn't indexable.
Tom Wright
see my edits to the answer above. I figure the query would look something like FB.Data.query("select name from event where eid in (select eid from event_member where uid = {0})", user_id);
Raine
This returns the names of the events that an entity owns, is attending, or has simply been invited to. There has to be another step - see Dustin's answer.
Tom Wright
+2  A: 

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.

Dustin Fineout
This is the answer that really answers the question and should have got the bounty. Unfortunately I was caught away from my PC and couldn't accept the answer on my phone. Sorry Dustin.
Tom Wright
Haha excellent :)
Dustin Fineout
+1  A: 

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

Sune

related questions