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

爱⌒轻易说出口 提交于 2019-12-05 03:45:09

问题


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


回答1:


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



回答2:


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'



来源:https://stackoverflow.com/questions/10904706/how-to-find-friends-past-checkins-near-a-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!