开发者

Facebook connect logout using link

Customer can sign in to my web app via normal login and facebook connect. So far so good.

<fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button>                                                  <div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
      FB.init({appId: '<xsl:value-of select="$FACEBOOK_APP_ID" />', status: true,
               cookie: true, xfbml: true});
                FB.Event.subscribe('auth.login', function(response) {
                window.location.reload();
      });
</script>

But when they come to logout, I want the customer to click on the logoff link at my website. How can I programmatically logout facebook connect? Possibly via json backend?

I don't want customer to click facebook button to logoff.

I did try out with some ways, example: to reset the facebook connect cookie created at my w开发者_运维问答ebsite and it works, but when I try to login to facebook again at second time, it fails.

I know delete cookie logout is simply not clean (fb autologoutlink=true is still showing I haven't logout.)

I can't let customer to click logout twice, I want them to use my web app logout link as a single logout controller.

I am using ASP classic. Any solution?


If the user has logged in via Facebook, call this JS snippet when the user logs out of your site (depending on how you implement logout, one possible way is to use onclick="", or if you redirect to the "logged out" template, include it there):

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: 'YOUR_APP_ID', status: true, cookie: true, xfbml: true});
    FB.logout(function(response) {});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>


You can use this simple code:

  <div id="fb-root"></div>
  <script src="http://connect.facebook.net/en_US/all.js"></script>
  <script>
     FB.init({ 
        appId:'APPID HERE', cookie:true, 
        status:true, xfbml:true 
     });
  </script>

and this:

<fb:login-button autologoutlink="true" length="short" background="white" size="large" data-show-faces="true" perms="email,user_birthday,status_update,publish_stream">Login with Facebook</fb:login-button>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜