Created
June 4, 2017 10:50
-
-
Save bussiere/c67138e744c1324528743b542d5ab8f7 to your computer and use it in GitHub Desktop.
fblogin.html
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
<html> | |
<head> | |
<title>Your Website Title</title> | |
<!-- You can use open graph tags to customize link previews. | |
Learn more: https://developers.facebook.com/docs/sharing/webmasters --> | |
<meta property="og:url" content="http://www.your-domain.com/your-page.html" /> | |
<meta property="og:type" content="website" /> | |
<meta property="og:title" content="Your Website Title" /> | |
<meta property="og:description" content="Your description" /> | |
<meta property="og:image" content="http://www.your-domain.com/path/image.jpg" /> | |
</head> | |
<body> | |
<script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<script> | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId : '132911310473896', | |
status : true, | |
xfbml : true, | |
version: 'v2.8' | |
}); | |
FB.Event.subscribe('edge.create', | |
function(response) { | |
alert('You liked the URL: ' + response); | |
} | |
); | |
FB.Event.subscribe('edge.remove', | |
function(response) { | |
alert('You UNliked the URL: ' + response); | |
} | |
); | |
FB.api('/me/likes/269509429847105', function(response) { | |
console.log(response.data); | |
alert(response.data); | |
}); | |
}; | |
(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#xfbml=1&version=v2.9&appId=132911310473896"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk')); | |
function login(){ | |
FB.login(function(response) { | |
if (response.authResponse) { | |
console.log('Welcome! Fetching your information.... '); | |
FB.api('/me', function(response) { | |
console.log('Good to see you, ' + response.name + '.'); | |
FB.api('/me/likes/269509429847105', function(response) { | |
console.log("like ?"); | |
alert("like ?"); | |
console.log(response.data); | |
alert(response.data); | |
console.log(response); | |
alert(response); | |
}); | |
}); | |
} else { | |
console.log('User cancelled login or did not fully authorize.'); | |
} | |
}); | |
}; | |
</script> | |
<div class="loginfb">Click here to log</div> | |
<!-- Load Facebook SDK for JavaScript --> | |
<div id="fb-root"></div> | |
<!-- Your like button code --> | |
<div class="fb-like" data-href="https://www.facebook.com/SidAliceFreak/" data-layout="button_count" data-action="like" data-size="large" data-show-faces="true" data-share="true" ></div> | |
<script> | |
var div = document.getElementsByClassName('loginfb')[0]; | |
div.addEventListener('click', function (event) { | |
console.log("inside"); | |
alert("inside"); | |
login(); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment