Question

I am trying to get User data(/me) & Friends data(/me/friends) using a function which fires after login through facebook. I am using Javascript SDK

//Getting logged in user data//
function users(callback) {    FB.api('/me?fields=name,first_name,username,birthday,hometown,albums,photos,location,picture.height(100).width(100),cover', function(response) {
        callback(response);

    });
}

//Getting logged in user friends data//
function pic(album_id, callback) {

    FB.api("/" + album_id + "/photos", function(response) {

        callback(response);

    });
}

By using this i am able to access all public data of logged in user, but not able to access data with limited permission(such as my location & Hometown is set to be visible to my friends only).

App dashboard permissions: enter image description here

Was it helpful?

Solution

You can access fields such as hometown,location etc. for an user using the following code, which asks for an authorization when you login to your app using facebook.

FB.login(function(response) {
      }, {
          scope: 'user_location,user_hometown,user_photos,friends_location'
      });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top