Luca S.
Luca S.

Reputation: 94

FQL: search events from their venue field

I'm developing an app that retrieves events via FQL from facebook Pages. it happens sometimes that the owners of these pages do not create these events from the Page profile, but from their own profile and just link the event to the page as the field Venue (since the pages I'm looking for are public places)

is it possible via FQL or any other mean to get all the events ID that have as venue a specific facebook page ID??

now i can get all the events only if the page owners insert the events via the page profile with the following code:

$fql    =   "SELECT eid, creator, name, pic, timezone, start_time, end_time, location, description 
            FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid IN  ($clubsstring) )
            AND start_time > $today
            AND start_time < $nextweek
            ORDER BY start_time asc";

$param  =   array(
    'method'    => 'fql.query',
    'query'     => $fql,
    'callback'  => ''
);

$fqlResult   =   $facebook->api($param);

thanks Luca

Upvotes: 2

Views: 2535

Answers (2)

I use this, it´s currently working.

{"eventos":"SELECT start_time, end_time, name, eid, pic,venue.id, location, creator, description 
FROM event WHERE eid IN  (SELECT eid FROM event_member WHERE uid IN (  SELECT uid2 FROM friend WHERE uid1=me() LIMIT 150) 
 OR uid = me() AND rsvp_status = 'attending') AND venue.id <>'' 
 AND location <> '' AND location <> '#data'","lugares":"SELECT latitude,longitude  
 FROM place WHERE page_id IN (SELECT venue.id FROM #eventos)"}

Upvotes: 1

Nitzan Tomer
Nitzan Tomer

Reputation: 164147

Well, you can indeed search based on venues, but that can only be a secondary condition since the venue field is not indexable.

This means that you first have to search based on eid (the only indexable field in the Event table), and then filter those results based on the venue.

The problem is that the venue field is an array, and the fields in it are not always there, for example one event might have this as venue:

"venue": {
    "id": VENUE_ID
}

But another will have:

"venue": {
    "street": "", 
    "city": "", 
    "state": "", 
    "country": ""
}

You should be able to get what you want with something like:

SELECT eid, creator, name, pic, timezone, start_time, end_time, location, description 
FROM event
WHERE 
    ((eid IN (SELECT eid FROM event_member WHERE uid IN ($clubsstring)))
    OR
    (eid IN (SELECT eid FROM event_member WHERE uid IN (OWNERS_IDS_STRING)))
    AND
    venue.id IN (VENUE_IDS_STRING))
    AND start_time > $today
    AND start_time < $nextweek
    ORDER BY start_time asc;

I haven't tested this query, and you might need to modify it a bit to work, also you can use a different field of venue other than the id.

Hope this helps.

Upvotes: 1

Related Questions