Is there a way to get the location of my facebook friends using the Graph API?
Your friend is considered a user, so you go to the user documentation, get the field name location (to be send in the fields parameter) AND you check if you need a specific permission:
Requires
user_locationorfriend_locationpermission
HOWEVER there's a typo! to get your friend's location you need the friends_location (with s), reference.
Here's a PHP-SDK example:
$facebook->api('/friend_id', 'get', array("fields"=>"name,location"));
Here I'm retrieving the name and location fields (please note that the id field will be retrieved automatically).
FB.api('/me', function(response) {
var location = response.location.name;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With