Facebook连接和断开连接

时间:2012-07-05 17:11:15

标签: facebook

我正在使用此代码在我的网站上创建Facebook连接按钮:

        <div id="fb-root"></div>
          <script>
            window.fbAsyncInit = function() {
              FB.init({
                apiKey: 'xxxxxxxxxxxxxxxxxxxMQTQ2DshKBkNG4aAZDZD',
                appId      : 'xxxxxxxxxxxxxxxx', // App ID
                channelUrl : '//www.xxx.net/channel.html', // Channel File
                status     : true, // check login status
                cookie     : true, // enable cookies to allow the server to access the session
                xfbml      : true  // parse XFBML
              });
              // Additional initialization code here
            };

            // 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));
             function logOut(){
                FB.logout();
             }
          </script>
          <div class="fb-login-button" data-show-faces="false" data-width="200" data-max-rows="1"></div>
          <a href="#" onclick="logOut();" >Logout</a>

当我点击登录按钮时,我登录但是当我点击登出链接时 我与Facebook断开连接(不是来自应用程序本身)

然后当我执行以下操作时: 1.再次登录(直接在facebook.com上) 2.去我的网站 3.点击登录,它已经连接到应用程序

我在做什么呢?

1 个答案:

答案 0 :(得分:1)

如果我理解正确,您也希望与应用程序断开连接?这不是它的工作原理。授权应用程序时,除非您将其从FB中的授权列表中删除,否则它将保持授权状态。注销只会让你退出FB。

当你登录FB时,由于你的应用已被授权,点击登录按钮进入FB会看到它已经授权,告诉你。