Facebook 需要电子邮件烫发和用户提示登录,尽管我没有问?

Facebook 需要电子邮件烫发和用户提示登录,尽管我没有问?,facebook,facebook-javascript-sdk,facebook-c#-sdk,Facebook,Facebook Javascript Sdk,Facebook C# Sdk,我正在使用JSSDK,获取基本信息,如姓名、位置、id。很好,但我还需要一件事,那就是电子邮件。所以我读到电子邮件需要扩展权限。我还阅读了使用fb.login如何要求延长烫发时间 在本教程的代码中,我没有调用fb.login,但是会提示访问者登录并授予应用程序权限(如果他们没有)。这是怎么做到的?register按钮(从教程中稍作修改)是一个div,它带有一个设置其样式的类 <div class="fb-login-button" data-show-faces="false" data-

我正在使用JSSDK,获取基本信息,如姓名、位置、id。很好,但我还需要一件事,那就是电子邮件。所以我读到电子邮件需要扩展权限。我还阅读了使用fb.login如何要求延长烫发时间

在本教程的代码中,我没有调用fb.login,但是会提示访问者登录并授予应用程序权限(如果他们没有)。这是怎么做到的?register按钮(从教程中稍作修改)是一个div,它带有一个设置其样式的类

<div class="fb-login-button" data-show-faces="false" data-width="400" data-max-rows="1">Register</div>
所以,让我困惑的是拼图中的各个部分是如何组合在一起的。我知道我需要请求扩展权限才能让json包含电子邮件,但不确定在哪里进行烫发。请求在

这里的代码是页面中的实际代码,因此您可以看到我的整个sdk实现

<div id="fb-root"></div>
        <script>
            window.fbAsyncInit = function ()
            {
                FB.init({
                    appId: 12324, // App ID
                    status: true, // check login status
                    cookie: true, // enable cookies
                    xfbml: true  // parse XFBML
                });

                //If user authorizes using fb account info:
                FB.Event.subscribe('auth.authResponseChange', function (response)
                {
                    if (response.status === 'connected') {
                        // the user is logged in and has authenticated your
                        // app, and response.authResponse supplies
                        // the user's ID, a valid access token, a signed
                        // request, and the time the access token 
                        // and signed request each expire
                        var uid = response.authResponse.userID;
                        var accessToken = response.authResponse.accessToken;

                        // send access token to server so we can fill in fields
                        var form = document.createElement("form");
                        form.setAttribute("method", 'post');
                        form.setAttribute("action", '/mypage');

                        var field = document.createElement("input");
                        field.setAttribute("type", "hidden");
                        field.setAttribute("name", 'accessToken');
                        field.setAttribute("value", accessToken);
                        form.appendChild(field);

                        document.body.appendChild(form);
                        form.submit();

                    } else if (response.status === 'not_authorized') {
                        // the user is logged in to Facebook, 
                        // but has not authenticated your app
                    } else {
                        // the user isn't logged in to Facebook.
                    }
                });


            };

            // Load the SDK Asynchronously
            (function (d) {
                var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
                if (d.getElementById(id)) { return; }
                js = d.createElement('script'); js.id = id; js.async = true;
                js.src = "//connect.facebook.net/en_US/all.js";
                ref.parentNode.insertBefore(js, ref);
            }(document));
        </script>

window.fbAsyninit=函数()
{
FB.init({
appId:12324,//appId
状态:true,//检查登录状态
cookie:true,//启用cookie
xfbml:true//解析xfbml
});
//如果用户授权使用fb帐户信息:
FB.Event.subscribe('auth.authResponseChange',函数(响应)
{
如果(response.status===“已连接”){
//用户已登录并已验证您的身份
//app和response.authResponse提供
//用户ID、有效访问令牌、签名
//请求,以及访问令牌的时间
//和签名的请求都将过期
var uid=response.authResponse.userID;
var accessToken=response.authResponse.accessToken;
//将访问令牌发送到服务器,以便我们可以填写字段
var form=document.createElement(“表单”);
form.setAttribute(“方法”,“post”);
setAttribute(“action”、“/mypage”);
var字段=document.createElement(“输入”);
field.setAttribute(“类型”、“隐藏”);
field.setAttribute(“名称”,“accessToken”);
field.setAttribute(“值”,accessToken);
表单。追加子项(字段);
文件.正文.附件(表格);
表单提交();
}else if(response.status===“未授权”){
//用户已登录到Facebook,
//但尚未验证您的应用程序
}否则{
//用户未登录到Facebook。
}
});
};
//异步加载SDK
(职能(d){
var js,id='facebook jssdk',ref=d.getElementsByTagName('script')[0];
if(d.getElementById(id)){return;}
js=d.createElement('script');js.id=id;js.async=true;
js.src=“//connect.facebook.net/en_US/all.js”;
ref.parentNode.insertBefore(js,ref);
}(文件);

由于您不是使用SDK本身登录,而是使用登录按钮,因此您必须通过按钮本身上设置为
数据范围=“…”
范围
参数请求权限,请参阅

另一种选择是移除按钮,然后调用
FB.login
onclick自己制作的按钮/链接。

BINGO!!*我知道它一定是按钮上的东西,现在我也明白了你发送的链接。我以前见过,但没有联系上。非常感谢。
<div id="fb-root"></div>
        <script>
            window.fbAsyncInit = function ()
            {
                FB.init({
                    appId: 12324, // App ID
                    status: true, // check login status
                    cookie: true, // enable cookies
                    xfbml: true  // parse XFBML
                });

                //If user authorizes using fb account info:
                FB.Event.subscribe('auth.authResponseChange', function (response)
                {
                    if (response.status === 'connected') {
                        // the user is logged in and has authenticated your
                        // app, and response.authResponse supplies
                        // the user's ID, a valid access token, a signed
                        // request, and the time the access token 
                        // and signed request each expire
                        var uid = response.authResponse.userID;
                        var accessToken = response.authResponse.accessToken;

                        // send access token to server so we can fill in fields
                        var form = document.createElement("form");
                        form.setAttribute("method", 'post');
                        form.setAttribute("action", '/mypage');

                        var field = document.createElement("input");
                        field.setAttribute("type", "hidden");
                        field.setAttribute("name", 'accessToken');
                        field.setAttribute("value", accessToken);
                        form.appendChild(field);

                        document.body.appendChild(form);
                        form.submit();

                    } else if (response.status === 'not_authorized') {
                        // the user is logged in to Facebook, 
                        // but has not authenticated your app
                    } else {
                        // the user isn't logged in to Facebook.
                    }
                });


            };

            // Load the SDK Asynchronously
            (function (d) {
                var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
                if (d.getElementById(id)) { return; }
                js = d.createElement('script'); js.id = id; js.async = true;
                js.src = "//connect.facebook.net/en_US/all.js";
                ref.parentNode.insertBefore(js, ref);
            }(document));
        </script>