Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 1.39 KB  |  hits: 50  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Facebook Login for Websites: Best practice to handle user Facebook logout?
  2. /*
  3.  * Init code for Facebook connect
  4.  */
  5. window.fbAsyncInit = function() {
  6.         FB.init({
  7.                 appId      : FACEBOOK_APP_ID, // App ID
  8.                 channelUrl : CHANNEL_URL, // Channel File
  9.                 status     : true, // check login status
  10.                 cookie     : true, // enable cookies to allow the server to access the session
  11.                 xfbml      : true,  // parse XFBML
  12.                 oauth      : true
  13.         });
  14.  
  15.         // check facebook login status
  16.         FB.getLoginStatus(function(response) {
  17.                 console.log("FB login status: " + response.status);
  18.                 if (response.status === 'connected') {
  19.                         showWelcome();  //display welcome message
  20.                 } else if (response.status === 'not_authorized') {
  21.                         // the user is logged in to Facebook, but not connected to the app
  22.                         showFbLogin();  //display Facebook Login button
  23.                 } else {
  24.                         // the user isn't even logged in to Facebook.
  25.                         showFbLogin();  //display Facebook Login button
  26.                 }
  27.         });
  28.  
  29.         // subscribe to facebook events
  30.         FB.Event.subscribe('auth.authResponseChange', function(response) {
  31.                 fbAuthResponseChanged(response);
  32.         });
  33. };