views:

81

answers:

1

Hi!

I am developing facebook app which needs to retrieve events created by some of my friends. Standard SQL query would look like this:

NSString *fql1 = @"SELECT "
 @"eid, name, tagline, id, pic_small,host, description, start_time, creator "
 @"FROM "
 @"event "
 @"WHERE "
 @"creator = 1111111111 OR creator = 2222222222 OR creator = 333333333";

Facebook allows only to filter tables by indexed fields (which is eid in this table). I assume I could to construct multiquery. Anyone could help with it? I spent some time googling it with no look. I need only one query so learning whole fbl for this has no sense for me at the moment.

BTW: there is a function events.get - you can filter by uid (documentation says):

parameter: uid - Filters by events associated with a user with this uid.

ASSOCIATED In what sense? are those creator's uids?, invited, attending or maybe? Why facebook documentation is so frustrating? When I try events.get with uid parameter it returns result with different creators ids than uid parameter. Graph API function: uid/events returns events user has been invited to, attended or other status but NOT necessarily created by him.

What am I missing here? I granted necessary permissions to my application, it connects, gets friend's event lists but not the events I want.

Seems so simple but I con not find straight-forward solution.

I'd appreciate any help.

+1  A: 

You can do something like this:

SELECT eid, name, tagline, pic_small,host, description, start_time, creator FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid=111 OR uid=222) AND (creator=111 OR creator=222)

Basically this says get the events user 111 or 222 is a member of and of those, only return the ones they've created. Because eid is an indexable field, FQL is okay with this, and is happy to do the additional (creator=111) trimming for you.

jcmoney
This looks very promissing. However - I get: The operation couldn’t be completed. (facebookErrDomain error 602.). What does this error means? Am I messing somewhere with request params or query is not allowed?
Lukasz
Sorry id is not a valid field, it's eid for the event table. I'll edit the query to fix this.
jcmoney
Yep. I did not pay attention as I know there is nid column in event table. http://developers.facebook.com/docs/reference/fql/event. Thank You. Error is gone, I am getting responce. However the is 0 results and I know there should be some.... hmmm .. I can not vote for this answer yet til I check it out.
Lukasz
Sorry. Your answer is perfect. I messed up something with creator ids. Thanks a lot. I learnt much out of your example, specifically that you can still narrow facebook results by non-indexed fields as long as you join it with AND after indexable filter.
Lukasz