javascript - FB.login 问题,需要显示灯箱而不是弹出窗口、Javascript SDK、iFrame 应用程序

标签 javascript facebook lightbox

我正在开发一个 facebook iFrame 应用程序,它将嵌入到 facebook 页面中。我选择了 iFrame,因为 FBML 已被 facebook 弃用。

我的申请已经准备好了,但我遇到了一个小问题

调用 FB.login 时,会出现一个弹出窗口。我的应用程序要求是,无论何时加载,它都应该检查用户是否被授权,如果没有则显示一个对话框,要求扩展权限/登录

问题: 弹出窗口是 Safari 默认阻止的新窗口形式,因为窗口是通过 javascript 而不是通过点击打开的,我希望它显示为 facebook 通常为 fbml 应用程序显示的灯箱/阴影

我在 http://developers.facebook.com/blog/post/312 阅读那个

Blockquote In order to make a more consistent and secure user experience when connecting accounts, we're changing the behavior of the dialog when a user connects accounts between your site and Facebook when the user is already logged in to Facebook. Previously, the Connect with Facebook dialog appeared in an IFrame "lightbox" within the browser window. After tomorrow's weekly code push, the dialog will pop up in a separate browser window, with an address bar, which matches the user login flow when the user is not logged in to Facebook and tries to connect accounts with your site. This will also make it easier for users to identify that the URL is trustworthy and coming from Facebook. Blockquote

但这个新功能显然对我没有帮助。

有什么解决方法吗?

我的代码:

 <script src="http://connect.facebook.net/en_US/all.js"></script>
    <script type="text/javascript">
        FB.init({ appId : '161077430577043', status : true, cookie : true, xfbml  : true });
        FB.getLoginStatus(function(response) {
            // alert("response: " + response.session);
            if (response.session) {
                // alert("response of getlogin status, permissions:  " + response.perms);
                login();
            }
            else{
                document.getElementById('loginStatus').innerHTML = "Login and Grant Permission";
                logMeIn();
            }
        });

        function logMeIn(){
            FB.login(function(response) {
                // alert("login!");
              if (response.session) {
                    // alert("Granted permissions: " + response.perms);
                    login();
                } else {
                    // alert("not logged in");
              }
            }, {perms:'read_stream,publish_stream,offline_access,friends_birthday,email'});
        }
        function login(){    
            FB.api('/me', function(response) {
                document.getElementById('login').innerHTML="Welcome " + response.name;
            });
            getFriendsData();
        }

        function getFriendsData(){
            //  fetches data from Graph API
        }

    </script>

最佳答案

我想出了解决这个问题的方法。 现在,我正在使用通过 PHP 和 signed_request 生成的 FBML 提示来获取权限。

我错过了重要的一点,一旦您获得了权限,无论使用何种 sdk,它们都将可用。即从 fbml 获得许可并将它们与 php 一起使用

关于javascript - FB.login 问题,需要显示灯箱而不是弹出窗口、Javascript SDK、iFrame 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3922993/

相关文章:

javascript - Prettyphoto undefined 不是一个函数

javascript - 单击标记时将谷歌地图移至左侧

javascript - 每 2 秒更新一次页面 - 未捕获的类型错误

android - 如何在 android 应用程序 webview 中使用 Facebook 访问 token

来自 node.js 的 Facebook access_token 失败

Facebook 分享: How to update the OG tags when loading a page using AJAX

jquery - 使用 jQuery 生成的跨度不会自动对焦灯箱图像

css - 灯箱 CSS 冲突

javascript - 在多个元素上应用 onchange 事件

javascript - HTML Canvas 和正确显示的小问题?