Facebook API: get user_location

Is there a way to get the location of my friends on facebook using the Graph API?

+6
facebook facebook-graph-api
source share
7 answers

A friend is considered a user, so you go to the user documentation , get the name of the location field (for sending to fields ) And you check if you need a specific permission:

Requires user_location or friend_location permission

CLOTHING A typo there! to get your friend’s location you will need friends_location (with s ) link .

Here is an example PHP-SDK:

 $facebook->api('/friend_id', 'get', array("fields"=>"name,location")); 

Here I retrieve the name and location fields (note that the id field will be automatically loaded).

+9
source share
 FB.api('/me', function(response) { var location = response.location.name; }); 
+2
source share

The fastest way to get all the information you want from friends of a user, you can use the FQL method:

 $this->api->api(array('method'=>'fql.query','query'=>"SELECT uid,name,first_name,middle_name,last_name,pic_square,hometown_location,current_location,profile_url,email,website FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())")); 

For a list of all tables with the corresponding column names, I refer to: Facebook FQL Reference

+2
source share

The FaceBook documentation contains the information you are looking for, including sample code and instructions. It is available at:

http://developers.facebook.com/docs/guides/canvas

You can also find a useful graphical API: http://developers.facebook.com/docs/api

+1
source share

https://graph.facebook.com/me/friends?access_token= "get this from the fb tool" & fields = location

+1
source share
 fql?q=SELECT locale,current_location from user where uid in(select uid2 from friend where uid1=me()) 

Requires user_location or friend_location permission

+1
source share
 FB.api('/me', function(response) { document.getElementById("UserLocation").innerHTML = response.location.name; }); 

In your HTML code call, UserLocation Id in any HTML tag. ex.

 <div id="UserLocation"></div> 
0
source share

All Articles