diff --git a/login/index.html b/login/index.html new file mode 100644 index 0000000..b3fd2e0 --- /dev/null +++ b/login/index.html @@ -0,0 +1,71 @@ +<!DOCTYPE html> +<html> +<head> +<title>Facebook Login JavaScript Example</title> +<meta charset="UTF-8"> +</head> +<body> +<script> + + function statusChangeCallback(response) { // Called with the results from FB.getLoginStatus(). + console.log('statusChangeCallback'); + console.log(response); // The current login status of the person. + if (response.status === 'connected') { // Logged into your webpage and Facebook. + testAPI(); + } else { // Not logged into your webpage or we are unable to tell. + document.getElementById('status').innerHTML = 'Please log ' + + 'into this webpage.'; + } + } + + + function checkLoginState() { // Called when a person is finished with the Login Button. + FB.getLoginStatus(function(response) { // See the onlogin handler + statusChangeCallback(response); + }); + } + + + window.fbAsyncInit = function() { + FB.init({ + appId : '382456482257502', + xfbml : true, + version : 'v6.0' + }); + + + FB.getLoginStatus(function(response) { // Called after the JS SDK has been initialized. + statusChangeCallback(response); // Returns the login status. + }); + }; + + + (function(d, s, id) { // Load the SDK asynchronously + var js, fjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(id)) return; + js = d.createElement(s); js.id = id; + js.src = "https://connect.facebook.net/en_US/sdk.js"; + fjs.parentNode.insertBefore(js, fjs); + }(document, 'script', 'facebook-jssdk')); + + + function testAPI() { // Testing Graph API after login. See statusChangeCallback() for when this call is made. + console.log('Welcome! Fetching your information.... '); + FB.api('/me', function(response) { + console.log('Successful login for: ' + response.name); + document.getElementById('status').innerHTML = + 'Thanks for logging in, ' + response.name + '!'; + }); + } + +</script> + + +<fb:login-button scope="public_profile,email" onlogin="checkLoginState();"> +</fb:login-button> + +<div id="status"> +</div> + +</body> +</html> \ No newline at end of file