Advertisement
ShawnsSpace

GET fb link

Sep 26th, 2015
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.     window.fbAsyncInit = function() {
  3.     // init the FB JS SDK
  4.     FB.init({
  5.       appId      : '', // App ID from the App Dashboard
  6.       status     : true, // check the login status upon init?
  7.       cookie     : true, // set sessions cookies to allow your server to access the session?
  8.       xfbml      : true,  // parse social plugins on this page
  9.       version    : 'v2.2' // use version 2.0
  10.     });
  11.  
  12.     FB.getLoginStatus(function(response) {
  13.       if (response.status === 'connected') {
  14.         // the user is logged in and has authenticated your
  15.         // app, and response.authResponse supplies
  16.         // the user's ID, a valid access token, a signed
  17.         // request, and the time the access token
  18.         // and signed request each expire
  19.         var uid = response.authResponse.userID;
  20.         var accessToken = response.authResponse.accessToken;
  21.             FB.api('/me?fields=id,name,link', function(response) {
  22.                     //alert('Your name is ' + response.name);
  23.                     var thisusername = '<div id="fbusername" style="font-size: 11.5px;">Welcome, <b>'+response.name+'</b></div>';
  24.                     var thisuserpic = '<div id="fbuserpic"><img src="https://graph.facebook.com/'+response.id+'/picture?type=normal"  id="theimage" width="82" style="border: 2px solid #000"/></div>';
  25.                     var theprofilename = document.getElementById('fbname');
  26.                     var theprofilepicture = document.getElementById('fbpic');
  27.                     theprofilename.innerHTML = ''+thisusername+'';
  28.                     theprofilepicture.innerHTML = ''+thisuserpic+'';
  29.                     document.getElementById("fbdialogbuttons").style.display="block";
  30.                     document.getElementById("fb-connect").style.display="block";
  31.                     document.getElementById("fb-notconnected").style.display="none";
  32.             });
  33.       } else if (response.status === 'not_authorized') {
  34.         // the user is logged in to Facebook,
  35.         // but has not authenticated your app
  36.         document.getElementById("fbdialogbuttons").style.display="none";
  37.         document.getElementById("fb-connect").style.display="none";
  38.       } else {
  39.         // the user isn't logged in to Facebook.
  40.         document.getElementById("fbdialogbuttons").style.display="none";
  41.         document.getElementById("fb-connect").style.display="none";
  42.       }
  43.      });
  44.     };
  45.       // Load the SDK Asynchronously
  46.       (function(d, s, id){
  47.          var js, fjs = d.getElementsByTagName(s)[0];
  48.          if (d.getElementById(id)) {return;}
  49.          js = d.createElement(s); js.id = id;
  50.          js.src = "//connect.facebook.net/en_US/sdk.js";
  51.          fjs.parentNode.insertBefore(js, fjs);
  52.        }(document, 'script', 'facebook-jssdk'));
  53.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement