1

我正在使用 javascript sdk 来实现 facebook 登录。是否可以将用户重定向到完整的登录页面而不是显示弹出窗口?我尝试添加 display : 'page' 但这似乎没有任何作用。

FB.init({

    appId: '123456789',
    cookie: true,
    status: true,
    xfbml: true,
    frictionlessRequests: true,
    oauth: true
});

function login() { //this function called on click of login button
   FB.login(function (response) {
    //my code
   }, { scope: 'email,publish_stream,read_stream,offline_access' });
});

谢谢

4

2 回答 2

3

登录总是在弹出窗口中打开。如果您希望它显示在完整页面而不是弹出窗口中,您应该考虑其他选项,例如设置该选项的服务器端身份验证display:page

于 2012-10-27T16:08:45.930 回答
2

这篇文章中的一个答案对我有用:Facebook 登录没有弹出窗口?

这是代码。它应该在之后运行window.onload

var APPID = "YOUR_APP_ID"
var uri = encodeURI('http://example.com');

FB.init({ appId: APP_ID,
          status: true, // check login status
       });
FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        //user is logged in
    } else {
        window.location = encodeURI("https://www.facebook.com/dialog/oauth?client_id=" + APPID + "&redirect_uri="+uri+"&response_type=token");
    }
});

为了完整起见,这里是加载 FB JS SDK 的代码。

// 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));
于 2014-03-26T23:29:40.853 回答