Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GibranPolonsky/bf32054fa93618b1ba7ddfad4f27a238 to your computer and use it in GitHub Desktop.
Save GibranPolonsky/bf32054fa93618b1ba7ddfad4f27a238 to your computer and use it in GitHub Desktop.
Facebook Login
$(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