Facebook user location using fb.api

流过昼夜 提交于 2020-01-05 10:25:14

问题


I want to allow my user's to login with facebook and while user do that i want to collect there information such as Name,Email,Location, Gender etc. There are two issues that i am facing

  1. FB.api not always returns me user's location.
  2. I am not able to get the user's birthday using user_birhtday. Code is given below.

    FB.getLoginStatus(function(response) {
        if (response.status === 'connected') {
            FB.api('/me?fields=age_range,name,location,email,gender', function(response) {
                //Get the user's Information
            });
        } else {
            FB.login(function(response) {
                if (response.authResponse) {
                    FB.api('/me?fields=age_range,name,location,email,gender', function(response) {
                        //Get the user's Information
    }); } else { // User is not logged in } }, { scope : 'email'}); } }, true); }

回答1:


You have a very clear list of permissions that you have to ask to query various parts of user data. Refer to the permissions section on user page (scroll to the end of page) and add them into your scope parameter.

For birthday and location you have to make the following change:

-- scope : 'email' 
++ scope : ['email','user_birthday','user_location']

and add the

birthday

field to your fields list.

This should solve your problem.



来源:https://stackoverflow.com/questions/21796003/facebook-user-location-using-fb-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!