Created
July 15, 2016 20:53
-
-
Save GibranPolonsky/bf32054fa93618b1ba7ddfad4f27a238 to your computer and use it in GitHub Desktop.
Facebook Login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
var app_id = "1733144626961713"; | |
var scopes ="email, user_friends"; | |
var btn_login = "<a id='login'>Iniciar Sesion</a>"; | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId : app_id, | |
status : true, | |
cookie : true, // enable cookies to allow the server to access | |
xfbml : true, // parse social plugins on this page | |
version : 'v2.5' // use graph api version 2.5 | |
}); | |
FB.getLoginStatus(function(response) { | |
statusChangeCallback(response); | |
}); | |
}; | |
var statusChangeCallback = function(response) { | |
console.log('statusChangeCallback', response); | |
if (response.status === 'connected') { | |
getFacebookData(); | |
} | |
} | |
var checkLoginState = function(callback) { | |
FB.getLoginStatus(function(response) { | |
statusChangeCallback(response); | |
}); | |
} | |
function getFacebookData(){ | |
} | |
var facebookLogin = function(){ | |
FB.login(function(response){ | |
FB.api( | |
"/me/taggable_friends", { fields: 'name,id,location,birthday,email' }, | |
function (res) { | |
if (res && !res.error) { | |
console.log(res); | |
} | |
} | |
); | |
}, {scope: scopes}); | |
} | |
$('#btnFacebook').click(facebookLogin); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment