Facebook登录没有弹出窗口? [英] Facebook login without pop-up?

查看:290
本文介绍了Facebook登录没有弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个简单的Facebook应用程序,但是对于授权,它似乎总是被一个弹出窗口拦截器阻止。我的代码是:

I'm trying to make a simple facebook app, but for the authorization, it seems that it's always blocked by a popup-blocker. My code is thus:

FB.init({
        appId  : THEAPPPIDDDD,
            status : true,
            cookie : true,
            xfbml  : true,
   });


FB.login(function(response) {
           if (response.authResponse) {
               FB.api('/me', function(response) {
               FB.logout(function(response) {
                               console.log('Logged out.');
                           });
                   });
           } else {
               console.log('User did not authorize.');
           }
       });

任何帮助将不胜感激...谢谢

Any help would be greatly appreciated... thanks

推荐答案

我知道这个问题可能与另一个问题:停止Facebook弹出窗口阻止程序我正在转发这个来帮助Dave Zhang。我已经修改了我的一个网站的代码。在以下代码中,替换YOUR_APP_ID和您的网站网址,然后Facebook的登录名将无弹出框。

I aware that this question is a possible duplicate of another question: Stop the facebook popup blocker I am reposting this to help Dave Zhang. I have adapted this code for one of my site. In the following code, replace the YOUR_APP_ID and your website url, then the Facebook login will be popup-less.

//Javascript
var uri = encodeURI('http://example.com');
FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        window.location.href=uri;
    } else {
        window.location = encodeURI("https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri="+uri+"&response_type=token");
    }
});

这将直接重定向而不是打开弹出窗口。

This will just redirect directly instead of opening a pop-up.

这篇关于Facebook登录没有弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆