I'm using Facebook Javascript SDK v2.5 and the facebook graph API to access the user location data (more specifically street, zip and city) with following code:
window.fbAsyncInit = function() {
FB.init({
appId : 'my_app_ID',
xfbml : true,
version : 'v2.5'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function logIntoFB(){
FB.login(function(){
testAPI();
}, {scope: 'public_profile,email,user_location'});
function testAPI() {
FB.api('/me?fields=name,first_name,last_name,location',function(response) {
console.log(response);
});
}
}
When the user logs in and the response is logged to the console, it looks as follows:
Object {name: "MyFirstName MyLastName", first_name: "MyFirstName", last_name: "MyLastName"
, id: "01010101010101"}
There is no location object present, so I cannot fetch the location.city, etc. The privacy settings of the specific facebook account were not altered and an address was provided, so the information should be retrievable. I already checked the Facebook SDK docs and various questions on StackOverflow, but nothing seems to work. Some of them being: "Facebook user location using fb.api" and "Retrieve zip code of a facebook user by facebook graph API"
Any help would be greatly appreciated.