How to search for friends by location?

How to search for friends around me using Facebook API?

  • Using GraphAPI, I see you can request location of a specific friend, or search for friends by criteria. However, I couldn't find a way to search for friends in my area. I want to perform a search and get a results of friends who are in a radius of X meters from me. I know I can fetch each friend manually and check its location, but it seems a bit inefficient so I'm looking for a batch search, EDIT: I've found a similar question (and answer) using FQL: http://stackoverflow.com/questions/6947647/facebook-fql-query-similar-to-friends-checkins

  • Answer:

    Well, you partly answered yourself there... When you query about a user friend, you get his location as well since it's part of the User object (assuming you have the right permissions of course): http://developers.facebook.com/docs/reference/api/user/ The problem, as you wrote, is that you'll need to send a request to facebook per friend, which is not the right way to go about this. Thankfully, facebook already thought of that and they came up with the "Batch Requests": http://developers.facebook.com/docs/reference/api/batch/ which let you do exactly that. EDIT Now that I think of it, it's simpler than I wrote before, you don't even need the batch requests since you can get all of the user friends in one request to: me/friends. Assuming you have the user granted you the needed permissions each user object in the friends list will have the location object as well. For each friend calculate if his location is in the desired radius.

Gilad at Stack Overflow Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.