Advertisement
davidfstr

FB login test page

Feb 17th, 2012
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.55 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Facebook Widget Demo</title>
  6. <!-- Dependencies -->
  7. <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
  8. <!-- Application -->
  9. <link rel="stylesheet" type="text/css" href="app.css" />
  10. <script type="text/javascript">
  11.  
  12. var FB_APP_ID = 'INSERT_APP_ID';
  13.  
  14. window.fbAsyncInit = function() {
  15.   FB.init({
  16.     appId: FB_APP_ID,
  17.     status: true, // check login status
  18.     cookie: true, // enable cookies to allow the server to access the session
  19.     xfbml: true   // parse XFBML
  20.   });
  21.  
  22.   $('#login').click(function(){
  23.     FB.login(function(response) {
  24.       if (response.authResponse) {
  25.         console.log('Success.');
  26.       } else {
  27.         console.log('User cancelled login.');
  28.       }
  29.     });
  30.   });
  31.  
  32.   $('#check-login-status').click(function(){
  33.     var force = false;
  34.     FB.getLoginStatus(function(response) {
  35.       console.log('Login status (force='+force+'):');
  36.       console.log(response);
  37.     }, force);
  38.   });
  39. };
  40.  
  41. // Load Facebook SDK asynchronously
  42. (function(d){
  43.   var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
  44.   js = d.createElement('script'); js.id = id; js.async = true;
  45.   js.src = "http://connect.facebook.net/en_US/all.js";
  46.   d.getElementsByTagName('head')[0].appendChild(js);
  47. })(document);
  48.  
  49. </script>
  50. </head>
  51. <body>
  52. <div id="fb-root"></div>
  53.  
  54. <a id="login" href="#">Login</a><br />
  55. <a id="check-login-status" href="#">Check Login Status</a>
  56.  
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement