Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- window.fbAsyncInit = function() {
- // init the FB JS SDK
- FB.init({
- appId : '', // App ID from the App Dashboard
- status : true, // check the login status upon init?
- cookie : true, // set sessions cookies to allow your server to access the session?
- xfbml : true, // parse social plugins on this page
- version : 'v2.2' // use version 2.0
- });
- FB.getLoginStatus(function(response) {
- if (response.status === 'connected') {
- // the user is logged in and has authenticated your
- // app, and response.authResponse supplies
- // the user's ID, a valid access token, a signed
- // request, and the time the access token
- // and signed request each expire
- var uid = response.authResponse.userID;
- var accessToken = response.authResponse.accessToken;
- FB.api('/me?fields=id,name,link', function(response) {
- //alert('Your name is ' + response.name);
- var thisusername = '<div id="fbusername" style="font-size: 11.5px;">Welcome, <b>'+response.name+'</b></div>';
- 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>';
- var theprofilename = document.getElementById('fbname');
- var theprofilepicture = document.getElementById('fbpic');
- theprofilename.innerHTML = ''+thisusername+'';
- theprofilepicture.innerHTML = ''+thisuserpic+'';
- document.getElementById("fbdialogbuttons").style.display="block";
- document.getElementById("fb-connect").style.display="block";
- document.getElementById("fb-notconnected").style.display="none";
- });
- } else if (response.status === 'not_authorized') {
- // the user is logged in to Facebook,
- // but has not authenticated your app
- document.getElementById("fbdialogbuttons").style.display="none";
- document.getElementById("fb-connect").style.display="none";
- } else {
- // the user isn't logged in to Facebook.
- document.getElementById("fbdialogbuttons").style.display="none";
- document.getElementById("fb-connect").style.display="none";
- }
- });
- };
- // Load the SDK Asynchronously
- (function(d, s, id){
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) {return;}
- js = d.createElement(s); js.id = id;
- js.src = "//connect.facebook.net/en_US/sdk.js";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement