Facebook Connect Login Button Not Displaying

I am trying to implement the Facebook Connect Single Sign-on website. I originally had a Connect button (<fb:login-button>) that the user had to click every time they wanted to enter. I now have automatic login and logout features. That is, my site will detect a registered Facebook account and automatically authenticate if it can match one of my user accounts and automatically deauthenticate if the Facebook session is lost. I also have a manual exit button that will bring the user out of my site and Facebook. They all work correctly, but now my original Connect button is temporarily not showing correctly. It simply displays as plain XHTML (i.e., it looks like plain text, not a button) and does not matter), and XFBML is not applied. Here is the basic code:

On each page:

<body>
{...}
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>

<script type="text/javascript>
FB.init('APIKey', '/xd_receiver.htm');

var isAuth; // isAuth determines if the user is authenticated on my site
            // it should be true on the logout page, false on the login page
FB.ensureInit(function(){ 
    var session = FB.Facebook.apiClient.get_session();
    if (session && !isAuth) {
        PageMethods.FacebookLogin(session.uid, session.session_key, FBLogin, FBLoginFail);
        // This is an AJAX call that authenticates the user on my site. 
    } else if(!session && isFBAuth) {
        PageMethods.FacebookLogout(FBLogout, FBLogoutFail);
        // This is an AJAX call that deauthenticates the user on my site.
    }
    // the callback functions do nothing at the moment
});
</script>

{...}
</body>

: ( )

<body>
{...}
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>

<script type="text/javascript>
    FB.init('APIKey', '/xd_receiver.htm');
    {...} // auto-auth code as on every page
</script>

<!-- This is the button that fails to render -->
<fb:login-button v="2" onlogin="UserSignedIntoFB();" size="large" autologoutlink="true"><fb:intl>Login With Your Facebook Account</fb:intl></fb:login-button>

<script type="text/javascript">
    function UserSignedIntoFB() {
        {...} // posts back to the server which authenticates the user on my site & redirects
    }
</script>
{...}
</body>      

: ( )

<body>
{...}
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>

<script type="text/javascript>
    FB.init('APIKey', '/xd_receiver.htm');
    {...} // auto-auth code as on every page
</script>

<script type="text/javascript">
    function FBLoggedOut() {
        {...} // posts back to the server which deauthenticates the user on my site & redirects to login
    }

    function Logout() {
        if (FB.Facebook.apiClient.get_session()) {
            FB.Connect.logout(FBLoggedOut); // logs out of Facebook if it a Facebook account
            return false;
        } else {
            return true; // posts back if it a non-Facebook account & redirects to login
        }
    }
</script>
<a onclick="return Logout();" href="postback_url">Sign Out</a>
{...}
</body>

, :

  • . Facebook , .
  • , , : Facebook, .
  • , , , Facebook , ; , , /.
  • cookie / , .
  • .
  • Facebook , . Facebook .
  • script .
  • : , , .

, - (, ), , Facebook Connect, , , ( deauthenticate ). ; - , ?

+5
1

facebook js include (FeatureLoader) , JS , . fb ...

, , .

+6

All Articles