Question

Problem

I am trying to get friends_location from the Facebok Graph API. I am accessing the API using the HybridAuth framework. How do I return a friend's location/hometown etc?

My App Permissions

I have set the following permissions for my app:

friends_about_me,friends_location,friends_hometown,user_location,email,user_birthday,offline_access,user_hometown

This is the request for permission screen the user sees on Facebook: Facebook Permissions Screen

What I Have Tried

I have tried the following methods to get the friend's details:

HybridAuth: $hybrid->getUserContacts();

and

Native API: $hybrid->api()->api('/me/friends');

Both return the following format without the friend's location:

{"identifier": "12345678","displayName": "Joe Smith",},

I have also seen this question but I have already included the friends_about_me permission in my request.

Was it helpful?

Solution

Take a look at the Graph API explorer:

https://developers.facebook.com/tools/explorer

Click on the "Get access token" button and select (under the Friends Data Permissions tab):

  • friends_hometown
  • friends_location

Once you have given the permissions for the access token click the friends link under connections in the right hand column. Your GET request should now look something like this:

https://graph.facebook.com/123456789/friends

You should now have a list of your friends with their name and id. If you click on the id you will see the results for that friend which include the hometown and location.

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top