facebook connect SDK示例:如何获取位置和生日?

亚雷克

我正在使用来自Facebook的官方样本:它工作正常,但我无法获取生日和位置。

<!DOCTYPE html>
<html>
<head>
<title>Facebook Login JavaScript Example</title>
<meta charset="UTF-8">
</head>
<body>
<script>
  // This is called with the results from from FB.getLoginStatus().
  function statusChangeCallback(response) {
    console.log('statusChangeCallback');
    console.log(response);
    // The response object is returned with a status field that lets the
    // app know the current login status of the person.
    // Full docs on the response object can be found in the documentation
    // for FB.getLoginStatus().
    if (response.status === 'connected') {
      // Logged into your app and Facebook.
      testAPI();
    } else if (response.status === 'not_authorized') {
      // The person is logged into Facebook, but not your app.
      document.getElementById('status').innerHTML = 'Please log ' +
        'into this app.';
    } else {
      // The person is not logged into Facebook, so we're not sure if
      // they are logged into this app or not.
      document.getElementById('status').innerHTML = 'Please log ' +
        'into Facebook.';
    }
  }

  // This function is called when someone finishes with the Login
  // Button.  See the onlogin handler attached to it in the sample
  // code below.
  function checkLoginState() {
    FB.getLoginStatus(function(response) {
      statusChangeCallback(response);
    });
  }

  window.fbAsyncInit = function() {
  FB.init({
    appId      : 'xxx',
    cookie     : true,  // enable cookies to allow the server to access 
                        // the session
    xfbml      : true,  // parse social plugins on this page
    version    : 'v2.2' // use version 2.2
  });

  // Now that we've initialized the JavaScript SDK, we call 
  // FB.getLoginStatus().  This function gets the state of the
  // person visiting this page and can return one of three states to
  // the callback you provide.  They can be:
  //
  // 1. Logged into your app ('connected')
  // 2. Logged into Facebook, but not your app ('not_authorized')
  // 3. Not logged into Facebook and can't tell if they are logged into
  //    your app or not.
  //
  // These three cases are handled in the callback function.

  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });

  };

  // Load the SDK asynchronously
  (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'));

  // Here we run a very simple test of the Graph API after login is
  // successful.  See statusChangeCallback() for when this call is made.
  function testAPI() {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me?fields=id,first_name,last_name,gender,location,email,birthday',  {fields: 'name, email,gender,first_name,last_name,location,birthday' }, function(response) {
        console.log(response);
      console.log('Successful login for: ' + response.name);
      document.getElementById('status').innerHTML =
        'Thanks for logging in, ' + response.name + '!';
    });
  }
</script>

<!--
  Below we include the Login Button social plugin. This button uses
  the JavaScript SDK to present a graphical Login button that triggers
  the FB.login() function when clicked.
-->

<fb:login-button show-faces="false" scope="public_profile,email,user_birthday,user_location" size="medium" onlogin="checkLoginState();">Connect with facebook</fb:login-button>


<div id="status">
</div>

</body>
</html>

这可以正常工作,但没有节假日,也没有位置作为回应。

我花了很多时间,看起来现在要检索这些信息,如今我需要在访问这些数据之前对应用程序进行审阅 Facebook的权利

https://developers.facebook.com/docs/facebook-login/review/what-is-login-review

这是正确的吗:我需要提交申请以进行审查还是我做错了什么?

托比

是的,这是真的,而且全部在文档中:

但是,如果您使用的是该应用程序的管理员/测试人员/开发人员,则可以使用您的应用程序授予和测试这些权限。仅当第三方需要访问该应用程序时,您才需要通过登录审核。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用Java的Facebook API和Facebook Connect?

Facebook登录和OpenID Connect

JSP中的Facebook Connect示例(tomcat)

无法获取Facebook Connect Android SDK的Release Keyhash

通过PHP 5.0 SDK获取Facebook生日

如何从Android中的Facebook获取用户性别和生日

Facebook Connect API:获取用户电子邮件

Facebook Connect:使用Facebook登录名的App Domains和网站之间的区别

Facebook如何在“ Facebook Connect”设置中设置带有FB Init调用的Cookies?

从Facebook SDK GraphUserCallback获取出生日期和城镇

Facebook SDK访问朋友的生日

寻找android Facebook SDK示例

Facebook javascript sdk随机询问生日许可

Facebook SDK更新后获得朋友的生日

隐式Facebook Connect PhoneGap(iOS / Android)

如何使用Facebook SDK Android获取Facebook照片,全名,性别

如何使用Android Facebook SDK从Facebook获取朋友列表?

如何从Facebook获取emailid使用facebook sdk版本3.22.0登录

如何使用Facebook Android SDK 3.8获取Facebook访问令牌?

获取用户生日Facebook图表

如何从Facebook iOS SDK获取朋友列表

我们可以从Android Facebook Sdk获取用户的生日吗?

无法获取Facebook SDK示例中的朋友列表的所有字段和Android中的朋友选择器示例中的ID仅获取名称

如何通过Facebook API获得生日?

如何使用JavaScript SDK在附加位置的位置发布到Facebook

Firebase网站在Google和Facebook中获取提供商数据(性别和生日)

使用facebook javascript sdk获取用户的位置

有谁知道如何从 android 平台的 facebook sdk 获取名字、姓氏、电子邮件、id、生日、性别、家乡、年龄等?

如何从Google OpenID Connect获取ID_token的示例