Login
Status:
waiting
|
Disconnect
|
Logout
<button id="fb-auth">Login</button> <script> function updateButton(response) { Log.info('Updating Button', response); var button = document.getElementById('fb-auth'); if (response.status === 'connected') { button.innerHTML = 'Logout'; button.onclick = function() { FB.logout(function(response) { Log.info('FB.logout callback', response); }); }; } else { button.innerHTML = 'Login'; button.onclick = function() { FB.login(function(response) { Log.info('FB.login callback', response); if (response.status === 'connected') { Log.info('User is logged in'); } else { Log.info('User is logged out'); } }); }; } } // run it once with the current status and also whenever the status changes FB.getLoginStatus(updateButton); FB.Event.subscribe('auth.statusChange', updateButton); </script>
Examples
Run Code
Website
Canvas
Page Tab
Clear