如果不共享sope字段,Facebook不会返回数据

时间:2013-06-25 13:07:10

标签: facebook facebook-javascript-sdk

您好我正在开发Facebook连接和访问用户电子邮件和签入。问题是 如果我不授予电子邮件地址或电子邮件的许可,那么facebook就不会返回数据。如果共享电子邮件,那么它运行正常。我想获取用户是否使用sahred电子邮件的数据。

<div id='fb-root'></div>
<a id='fb-login' href='javascript:void(0);' onclick='facebookLogin();'>
<img src="/images/spacer.gif" class="fb_btn" alt="Login with Facebook">
</a>
<script language="javascript">

window.fbAsyncInit = function() {
    FB.init({
        appId: '<?php echo $this->app_id; ?>',
        status: true,
        cookie: true,
        xfbml: true,
        oauth: true
    });
};

function facebookLogin() {
    FB.login(function(response) {
        if (response.authResponse) {

            //alert('authenticated');
             window.location = "comingsoon/loginfacebook"; //or do whatever you want
        } else {
            //console.log('User cancelled login or did not fully authorize.');
            //alert('User cancelled login or did not fully authorize.');
            window.location = "comingsoon/loginfacebook"; //or do whatever you want
        }
    },{
        scope: 'email,user_checkins'
    }
    );
}

(function(d) {
    var js,
    id = 'facebook-jssdk';
    if (d.getElementById(id)) {
        return;
    }
    js = d.createElement('script');
    js.id = id;
    js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    d.getElementsByTagName('head')[0].appendChild(js);
} (document));

</script>

1 个答案:

答案 0 :(得分:0)

除非您请求并接受相关范围,否则无法获取数据。