how to find friend's past checkins near a location?

1.6k views Asked by At

In my app, a user is at a location and is looking for her friends who have been anywhere withing 10 miles of where she is. How do I find this with either FQL or graph? The only way that I can see is by running a search like so: https://graph.facebook.com/search?type=checkin and then running through the results to find out which location was within 10 miles. Is there a better way for this?

Thanks for your help!

Doles

2

There are 2 answers

1
doles On BEST ANSWER

Although the initial answer did work for me for part of my purpose, it quickly became inadequate. Now, after banging my head against the wall, it finally broke (not my head - the wall). Here are two more BETTER ways that WORK to find what I need:

This is to find just checkins:

SELECT checkin_id, coords, tagged_uids, page_id FROM checkin WHERE (author_uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) or author_uid=me()) and coords.latitude<'45.0' and coords.latitude>'29' and coords.longitude>'-175' and coords.longitude<'-5';

This is to find all location posts:

SELECT id, page_id FROM location_post WHERE (author_uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) or author_uid=me()) and coords.latitude<'45.0' and coords.latitude>'29' and coords.longitude>'-175' and coords.longitude<'-5'

4
DMCS On

From http://developers.facebook.com/docs/reference/fql/location_post/

It says

An FQL table that returns Posts that have locations associated with them and that satisfy at least one of the following conditions:

  • you were tagged in the Post
  • a friend was tagged in the Post
  • you authored the Post
  • a friend authored the Post

Note: This query can process a large amount of data. In order to ensure that a manageable amount of data is returned within a reasonable timeframe, you should specify a recent timestamp to narrow the results.

Return posts within 10,000 meters of a given location:

SELECT id, page_id
FROM location_post
WHERE distance(latitude, longitude, '37.86564', '-122.25061') < 10000