我无法从 Facebook 帐户获取邮件 ID 和手机号码等

i am not able to getting mail id and mobile no etc from facebook account

我们正在开发混合移动应用程序,因为我们有登录页面。

我们想通过 Facebook 等社交网络登录,google.we 从 Facebook 成功登录,但我们想获取 Facebook 帐户详细信息,如用户名、邮件 ID、手机号码和地址等。

我正在获取用户名,但我没有获取到。请任何人帮助我我做错了什么以及必须做的事情 do.Below 我给了代码也请找到它。

function fblogin() {
 FB.login(function(response) {
  if (response.authResponse) {
   alert("if");
   getUserInfo(); // Get User Information.
  } else {
   console.log('Authorization failed.');
  }
 }, {
  scope : 'email'
 });

}

function getUserInfo() {
 FB.api('/me', {fields: 'name, username, password, email, first_name, middle_name, last_name, gender, hometown, birthday'}, function(response) {
  alert("name=" + response.name);
  alert("username=" + response.username);
  alert("password=" + response.password);
  alert("id=" + response.id);
  alert("email=" + response.email);
  alert("first_name=" + response.first_name);
  alert("middle_name=" + response.middle_name);
  alert("last_name=" + response.last_name);
  alert("gender=" + response.gender);
  alert("hometown=" + response.hometown);
  alert("birthday=" + response.birthday);
 });
 $.mobile.navigate("#dashboardPage");
}
<!DOCTYPE HTML>
<html>
     <head>
      <meta charset="UTF-8">
      <title>LoginSN</title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
      <!--
       <link rel="shortcut icon" href="images/favicon.png">
       <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> 
      -->
      <link href="jqueryMobile/jquery.mobile-1.4.5.css" rel="stylesheet">
      <link rel="stylesheet" href="css/main.css">
      <script>window.$ = window.jQuery = WLJQ;</script>
      <script src="jqueryMobile/jquery.mobile-1.4.5.js"></script>
   <script>
     
    window.fbAsyncInit = function() {
     FB.init({
      appId : '1608113949506014',
      xfbml : true,
      version : 'v2.6'
     });
    };

    (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'));
   </script>
  </head>
  
     <body style="display: none;">
     
      <div data-role="page" id="loginPage">
       <div data-role="content" style="padding: 15px">
        <h1 id="fb-welcome"></h1>
     <label for="text">User Name:</label><input type="text" name="text" id="unL">
     <label for="text">Password:</label><input type="password" name="text" id="pwdL">
     <a href="#dashboardPage" data-role="button" id="buttonLn">LOGIN</a>
     <a href="#registrationPage" data-role="button" id="buttonRe">REGISRASTION</a>
     <a href="#" data-role="button" id="buttonF" onclick="fblogin()">via Facebook Login</a>
     <a href="#" data-role="button" id="login">via Google Login</a>
     <a href="#" data-role="button" id="buttonT">via Twitter Login</a>
    </div>
      </div>
      
      <div data-role="page" id="registrationPage">
       <div data-role="content" style="padding: 15px">
        <label for="text">Name:</label><input type="text" name="text" id="unR">
     <label for="text">DOB:</label><input type="date" name="text" id="pwdR">
     <label for="text">Contact No:</label><input type="number" name="text" id="pwdR">
     <label for="text">Email ID:</label><input type="email" name="text" id="pwdR">
        <label for="text">User Name:</label><input type="text" name="text" id="unR">
     <label for="text">Password:</label><input type="password" name="text" id="pwdR"> 
     <a href="#loginPage" data-role="button" id="buttonR">Registered</a>
  </div>
      </div>
      
      <div data-role="page" id="dashboardPage">
       <div data-role="content" style="padding: 15px">
        
       </div>
      </div>
      
      <script src="js/initOptions.js"></script>
      <script src="js/main.js"></script>
      <script src="js/messages.js"></script>
      
     </body>
</html>

FB.api('/me', {fields: 'name,email,first_name,last_name'}, function(response) {
    ...
});

它被称为"Declarative Fields",你必须在API调用中指定你想要获取的字段。

顺便说一句,根本不可能得到 phone 号码或用户名(只有真实姓名)。

用户的现有字段table:https://developers.facebook.com/docs/graph-api/reference/v2.6/user

现有权限:https://developers.facebook.com/docs/facebook-login/permissions

更多信息:https://developers.facebook.com/docs/apps/changelog