简体   繁体   English

每当用户尝试从我的网站使用Facebook登录时,都会获得facebook登录弹出窗口

[英]Get facebook login popup every time user try to Login using facebook from my website

I am trying to implement Facebook login on my website as part of authentication and using Facebook JavaScript SDK for that. 我正在尝试在我的网站上实现Facebook登录,作为身份验证的一部分,并为此使用Facebook JavaScript SDK。

used a simple code as 用一个简单的代码作为

window.fbAsyncInit = function() {
FB.init({ appId: 'xxxxxxxxxxxxx', //change the appId to your appId
    status: true, 
    cookie: true,
    xfbml: true,
    oauth: true});

function updateButton(response) 
{       
    if (response.status === 'connected') 
    {
        $('#fb-auth').on('click',function(){
            FB.api('/me', function(info) {
                login(response, info);
            });


            //FB.logout(function(response) {
                //logout(response);
            //});
        });
    }
    else 
    {
        $('#fb-auth').on('click',function(){
            FB.login(function(response) {
                if (response.authResponse) {
                    FB.api('/me', function(info) {
                        login(response, info);
                    });    
                } 
                else {
                    ;
                }
            }, {scope:'email,user_birthday,status_update,publish_stream,user_about_me'});   
        });
    }
}
FB.getLoginStatus(updateButton);
//FB.Event.subscribe('auth.statusChange', updateButton);  
};    

Facebook login works fine but what I am trying to do is when next time they try Login with Facebook , they should get login pop-up and option to login as another user. Facebook登录正常,但是我要尝试的是下次他们尝试使用Facebook登录时,他们应该会弹出登录窗口,并可以选择以其他用户身份登录。

After first login , next time when they are trying to login with facebook again and they are logged into facebook in another tab its just redirecting them to logged in page without any pop-up or anything. 首次登录后,下次当他们尝试再次登录facebook时,又在另一个选项卡中登录了facebook,它只是将其重定向到登录页面,而没有任何弹出窗口或任何内容。

Can anyone please give me some pointer as what need to be done to achieve that. 任何人都可以给我一些指导,以实现该目标需要做什么。

If you want to login the user everytime he visits the app, you should implement FB.logout , when you get the status as connected on getLoginStatus() when the app starts. 如果要在用户每次访问该应用程序时登录,则应在应用程序启动时在getLoginStatus()上获得connected状态时,实现FB.logout

So the session when be destroyed and then you can call FB.login again. 因此,会话在被销毁时可以再次调用FB.login Just like- 就像-

// app starts here
FB.getLoginStatus()
{
    if(status == "connected")

        // call FB.logout()
        // call FB.login()

    else

        // call FB.login()

 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM