用户位置未定义

时间:2019-03-16 10:03:41

标签: facebook-graph-api facebook-javascript-sdk

我正在获取所有其他用户信息,但是location将始终为undefined。 我的FB位置已启用,弹出窗口要求此权限(hometowncurrent city),所以我得到了家乡/名称/等,但没有位置。

 FB.login(function(response) {
                if (response.status === 'connected')
                {
                  console.log("connected");
                  console.log('Access Token: ' + response.authResponse.accessToken);


                  var uid = response.authResponse.userID;
                  var accessToken = response.authResponse.accessToken;

                  testAPI();
                }
                else
                 {
                  console.log("not connected");
                 }
              },{scope: 'email,user_birthday,user_location,user_hometown'});



 function testAPI()
   {

      console.log('Welcome!  Fetching your information.... ');


      FB.api('/me', {fields: 'name,email,birthday,hometown,location'}, (response) => {
              console.log('name: ' + response.name);
              console.log('email: ' + response.email);
              console.log('birth: ' + response.birthday);
              console.log('home: ' + response.hometown.name);
              console.log('location: ' + response.location.name);






         });

   }

还尝试了location.namelocation,无效。

在这里的一些示例中包含了token,但是在FB或此处没有人清楚地谈论它,并且我不清楚是否需要它以及何时需要它。

0 个答案:

没有答案