Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook FQL: Get checkins within range

Is there a way to use FQL to select all my friends Checkins that are in range of a specified location? I can use FQL to return my friends checkin coords:

https://api.facebook.com/method/fql.query?access_token={0}&query=SELECT coords FROM checkin WHERE author_uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

but how can I add to the above query to do something like...

Where coords Within 10 miles of [(New York City, NY) | (long, lat) | (user.current_location)]

Any help would be greatly appreciated. Thanks in advance.

EDIT (3/9 3:05pm est):

I'm mainly just looking for an end result - doesn't need to get everything back in a single FQL statement, or even use FQL (graph api, possibly?) I understand I may need to bring it back data back in pieces and work with it locally due to the limitations of FQL/the graph api. I just want to do it in an efficient manner so a user doesn't have to wait 20secs for everything to load.

The immediate problem is that if someone has several hundred friends and all checkins for each friend are returned, that's too much data to work with.

The granular details of the result I'm looking for is to start with all my friends, and end up with the top 10 places (based of highest frequency of the checkin's location ID) they checked into within the last X days, that are within Y distance of the users current facebook location, and where the location's page falls into a certain category, like a bar.

That's the scenario I'm dealing with and I hope the additional information I appended doesn't complicate my original question. Thanks!

like image 283
StronglyTyped Avatar asked Dec 29 '22 00:12

StronglyTyped


1 Answers

So there's some undocumented function called distance() that might help you, although it doesn't work so well (especially since it's limited to 50km radius):

SELECT coords, author_uid, tagged_uids, target_id, message FROM checkin WHERE target_id IN
(SELECT page_id FROM place WHERE distance(latitude, longitude, "37.75377496892", "-122.42077080676") < 50000)

Max is 50,000 meters, which is the output unit of FQL's (apparently undocumented) distancefunction.

https://developers.facebook.com/docs/reference/fql/checkin/ https://developers.facebook.com/docs/reference/fql/place

like image 85
phreakhead Avatar answered Jan 03 '23 15:01

phreakhead