I'm using multi queries with FQL, I have 3 queries actually.
The third one is the one that interests me the most, however Facebook returns the result of the previous queries first, which means more overhead for me to process and more time to stream in the result. Is there a way to limit Facebook into only sending the result set of the 3rd query?
JSONqueries["query1"] = encodeURIComponent('SELECT uid1 FROM friend WHERE uid2 = me()');
JSONqueries["query2"] = encodeURIComponent('SELECT eid FROM event_member WHERE uid IN (SELECT uid1 FROM #query1)');
JSONqueries["query3"] = encodeURIComponent('SELECT eid, start_time, end_time, update_time, location, venue FROM event WHERE eid IN (SELECT eid FROM #query2) and privacy=\'OPEN\'');
Here you are. But it's still too complex and therefore extremely slow.
SELECT eid, start_time, end_time, update_time, location, venue FROM event WHERE eid IN(SELECT eid FROM event_member WHERE uid IN (SELECT uid1 FROM friend WHERE uid2 = me())) and privacy="OPEN"
Related
I tried to limit to a latitude/longitude range but don't know how to do it
Here's what I've tried
SELECT name, venue, location, start_time, eid FROM event
WHERE eid IN (
SELECT eid FROM event_member
WHERE (uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) OR uid = me())
)
AND start_time > now()
AND venue.latitude < '-22.821757'
AND venue.latitude > '-23.056989'
but the coordinate comparison doensn't work because i'm comparing to a string
If I take away the quotes I get:
(#601) Parser error: unexpected '-' at position 233
https://developers.facebook.com/tools/explorer
Thanks
Simply put. I need help building an FQL multi query request that will do the following:
Grab the UIDs in from the logged in user's friends list then,
Use those IDs to grab all comments and messages (from stream) from the last two weeks
Finally, join those results with there usernames
Heres the queries I have so far:
[1] GRAB_UIDs:
SELECT uid2 FROM friend WHERE uid1 = me()
[2] GRAB_STREAM (missing the 2 week part and possibly wrong altogether):
SELECT type, created_time, post_id, comments, actor_id, target_id, message
FROM stream
WHERE filter_key IN
(SELECT filter_key FROM stream_filter WHERE uid = me())
AND actor_id IN
(SELECT uid2 FROM friend WHERE uid1 = me())
)';
[3] GRAB_USRNAMES:
SELECT uid, name, username, pic_square, current_location, profile_url
FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = me())
I could really use a master at making these kind of requests and I greatly appreciate the help.
{
"query1":"SELECT uid2 FROM friend WHERE uid1 = me()",
"query2":"SELECT type, created_time, post_id, comments, actor_id, target_id, message FROM stream WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid = me()) AND actor_id IN (SELECT uid2 FROM #query1)",
"query3":"SELECT uid, name, username, pic_square, current_location, profile_url FROM user WHERE uid IN (SELECT uid2 FROM #query1)"
}
You can also see the results from the Graph API Explorer at:
https://developers.facebook.com/tools/explorer?fql={%22query1%22%3A%22SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me%28%29%22%2C%22query2%22%3A%22SELECT%20type%2C%20created_time%2C%20post_id%2C%20comments%2C%20actor_id%2C%20target_id%2C%20message%20FROM%20stream%20WHERE%20filter_key%20IN%20%28SELECT%20filter_key%20FROM%20stream_filter%20WHERE%20uid%20%3D%20me%28%29%29%20AND%20actor_id%20IN%20%28SELECT%20uid2%20FROM%20%23query1%29%22%2C%22query3%22%3A%22SELECT%20uid%2C%20name%2C%20username%2C%20pic_square%2C%20current_location%2C%20profile_url%20FROM%20user%20WHERE%20uid%20IN%20%28SELECT%20uid2%20FROM%20%23query1%29%22}
I am trying to use FQL to get a list of my own photos that have friends tagged in them. The friends are specified by their name or part of their name. i.e input from a text box
So far I have come up with the FQL below, which almost works, but...
Can anyone tell me why the first query returns a list of records but the second query returns nothing? the only difference between the two is the second one searches on just part of the person's name i.e "laura" vs "lau"
FQL 1
SELECT object_id, src_big, src_big_width, src_big_height, aid
FROM photo
WHERE object_id in (
SELECT object_id
FROM photo_tag
WHERE subject in (
SELECT uid
FROM user
WHERE (strpos(lower(name),"laura") >=0 )
AND (uid in (SELECT uid2 FROM friend WHERE uid1 = me()) ))
)
AND owner = me()
FQL 2
SELECT object_id, src_big, src_big_width, src_big_height, aid
FROM photo
WHERE object_id in (
SELECT object_id
FROM photo_tag
WHERE subject in (
SELECT uid
FROM user
WHERE (strpos(lower(name),"lau") >=0 )
AND (uid in (SELECT uid2 FROM friend WHERE uid1 = me()) ))
)
AND owner = me()
It looks like Facebook has a bug in its system so strpos doesn't work as expected in sub queries. As a workaround you could try splitting it into two queries - one that finds list of id-s:
SELECT uid
FROM user
WHERE (strpos(lower(name),"lau") >=0 )
AND (uid in (SELECT uid2 FROM friend WHERE uid1 = me()) )
And a second one that uses this list:
SELECT object_id, src_big, src_big_width, src_big_height, aid
FROM photo
WHERE object_id in (
SELECT object_id
FROM photo_tag
WHERE subject in (111,222,333,444,555)
)
AND owner = me()
I am working on a custom Events app in Facebook and have ran into an issue where the response seems quite slow. The slowness mostly relate to trying to search for a page that is associated with an events geographical location. I.e "City, Country". Once such URL would be:
http://www.facebook.com/pages/Buenos-Aires-Argentina/106423786059675
I've already determined that it is possible to obtain the page URL for a page like this with the following FQL query:
SELECT page_id, page_url FROM page WHERE name = "Buenos Aires, Argentina" AND type = "CITY"
The type column equals CITY is important, as otherwise other non-relevant pages URLs may be returned.
Anyhow, in order to get all events by a user and display their rsvp status, display information about the venue and also get the geographic places page URL I'm running the following mult-query FQL:
[events_query] => SELECT eid, name, pic_square, start_time, end_time, location, description, all_members_count, venue FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid = 6747251459 AND start_time > 0) AND start_time > 0 AND end_time < now() ORDER BY start_time desc LIMIT 5
[rsvp_query] => SELECT eid, rsvp_status FROM event_member WHERE eid IN (SELECT eid FROM #events_query) AND uid = YOUR_EVENTS_UID
[venue_page_id_query] => SELECT page_id FROM place WHERE page_id IN (SELECT venue.id FROM #events_query)
[venue_info_query] => SELECT page_id, name, page_url, location FROM page WHERE page_id IN (SELECT page_id FROM #venue_page_id_query)
[geo_city_country_query] => SELECT name, page_url FROM page WHERE name IN (SELECT concat(location.city, ', ', location.country) FROM #venue_info_query) AND type = "CITY"
My problem is that when doing the "geo_city_country_query" the response slows down quite a bit. To approx +5seconds. Without the "geo_city_country_query" query, the response time is approx 1.5sec-2sec.
Is there any way I can get this done faster?
Thanks in advance!
I am trying to find all my friends who are are attending a particular event of interest. I think the right way to do it is with FQL. What would be the query to do that?
Based on the example in the event_member fql table:
SELECT uid FROM event_member WHERE eid = ... AND rsvp_status = 'attending'
I suppose you could use something like:
SELECT uid FROM event_member WHERE eid = ... AND rsvp_status = 'attending' AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())