Created
September 14, 2014 04:49
-
-
Save edpittol/3492b086affcc5100708 to your computer and use it in GitHub Desktop.
Parse 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
// Initialize the Facebook SDK with Parse as described at | |
// https://parse.com/docs/js_guide#fbusers | |
window.fbAsyncInit = function() { | |
// init the FB JS SDK | |
Parse.FacebookUtils.init({ | |
appId : '289802934544559', // Facebook App ID | |
cookie : true, // enable cookies to allow the server to access | |
// the session | |
xfbml : true, // parse social plugins on this page | |
version : 'v1.0' // use version 1 | |
}); | |
// Additional init code here | |
FB.getLoginStatus(function(response) { | |
if (response.status === 'connected') { | |
FB.api('/me', function(response) { | |
console.log(response); | |
}); | |
} | |
}); | |
$("#fb-login").on("click", function(){ | |
Parse.FacebookUtils.logIn("email,public_profile", { | |
success: function(user) { | |
console.log("Success"); | |
console.log(user); | |
}, | |
error: function(user, error) { | |
console.log("Error"); | |
console.log(error); | |
console.log(user); | |
} | |
}); | |
}); | |
}; | |
(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')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment