1

我想在我的网站上有一个连接按钮。一旦用户点击了 facebook 登录按钮,弹出窗口将要求用户输入身份验证详细信息,父窗口将重定向或刷新页面,登录按钮变成注销按钮。

我的问题是当用户从弹出窗口中单击连接按钮时,弹出页面将重定向到我的画布页面,而不是关闭弹出窗口。

4

2 回答 2

2

很多人都发布了这个问题,如果你做的一切都正确,这是因为 fb 没有读取 xd_receiver 文件。

您需要确保您的 fb 连接按钮所在的位置,在该页面底部的某处指定 xd_receiver.html 文件的正确路径。如下所示:

<script type="text/javascript">
    FB.init("your api key here", "xd_receiver.htm");
</script>

将 xd_receiver 文件放在站点的根文件夹中并使用完整的域 url 指定它会更好、更容易,如下所示:

<script type="text/javascript">
    FB.init("your api key here", "http://www.yoursite.com/xd_receiver.htm");
</script>
于 2009-12-12T05:47:30.827 回答
0

这是 facebook 连接、登录和注销的示例,效果很好,另外请确保在您的应用设置 -> 网站 -> 网站 URL 下添加您的站点 URL:您的网站网址

<!DOCTYPE html> 
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> 
        <head> 
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
            <title>Facebook Connect Sample</title> 
        </head> 
        <body> 
            <div id="fb-root"></div> 
            <script> 
            window.fbAsyncInit = function() {
                FB.init({
                  appId  : 'YOUR APP ID',
                  status : true, // check login status
                  cookie : true, // enable cookies to allow the server to access the session
                  xfbml  : true  // parse XFBML
                });

            /* All the events registered */
            FB.Event.subscribe('auth.login', function(response) {
                // do something on login
                login();
            });
            FB.Event.subscribe('auth.logout', function(response) {
                // do something on logout
                logout();
            });

            FB.getLoginStatus(function(response) {
                if (response.session) {
                    // logged in and connected user, someone you know
                    login();
                }
            });
        };

      /* Loading the JS SDK Asynchronously - Refer: https://developers.facebook.com/docs/reference/javascript/ */
      (function() {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
      }());

    function login(){
        window.location = "http://google.com"; // Redirect to Another Page.

        /* Show User's Name 
        FB.api('/me', function(response) {
            document.getElementById('login').style.display = "block";
            document.getElementById('login').innerHTML = response.name + " succsessfully logged in!";
        });
        */
    }
    function logout(){ 
        document.getElementById('login').style.display = "none";
    }
    </script> 
    <p><fb:login-button autologoutlink="true"></fb:login-button></p> 
        <div id="login" style ="display:none"></div> 
</body> 
</html>
于 2011-07-07T08:25:20.913 回答