Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="fb-root"></div>
- <script>
- window.fbAsyncInit = function() {
- FB.init({
- appId : '142859072412938',
- status : true, // check login status
- cookie : true, // enable cookies to allow the server to access the session
- xfbml : true, // parse XFBML
- //channelUrl : '', // channel.html file
- oauth : true // enable OAuth 2.0
- });
- FB.Event.subscribe('auth.login', function(response){
- location.reload();
- });
- FB.Event.subscribe('auth.logout', function(response){
- location.reload();
- });
- 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', function(response) {
- //alert('Your name is ' + response.name);
- var thisusername = '<div id="thename">'+response.name+'</div>';
- var thisuserpic = '<div id="image"><img src="'+response.picture+'" id="theimage" /></div>';
- var theprofilebox = document.getElementById('user_profile ');
- theprofilebox.innerHTML = ''+thisusername+' <br /> '+thisuserpic+'';
- });
- } else if (response.status === 'not_authorized') {
- // the user is logged in to Facebook,
- // but has not authenticated your app
- } else {
- // the user isn't logged in to Facebook.
- }
- });
- };
- // 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/all.js";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement