Created
December 24, 2019 06:42
-
-
Save joe-oli/40da2afff4ddab28562dbb0555148a0f to your computer and use it in GitHub Desktop.
facebook login api sdk js
This file contains hidden or 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
<!DOCTYPE html> | |
<html xmlns:fb="http://www.facebook.com/2008/fbml"> | |
<head> | |
</head> | |
<body> | |
<a href="#" onClick="postToFacebook()">Post to Facebook</a> | |
<script> | |
function postToFacebook() { | |
var body = 'Reading Connect JS documentation'; | |
FB.api('/me/feed', 'post', { body: body, message: 'My message is ...' }, function(response) { | |
if (!response || response.error) { | |
alert('Error occured'); | |
} else { | |
alert('Post ID: ' + response); | |
} | |
}); | |
} | |
</script> | |
<div id="fb-root"></div> | |
<script> | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId : 'YOUR APP ID GOES HERE', | |
status : true, // check login status | |
cookie : true, // enable cookies to allow the server to access the session | |
xfbml : true // parse XFBML | |
}); | |
}; | |
(function() { | |
var e = document.createElement('script'); | |
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; | |
e.async = true; | |
document.getElementById('fb-root').appendChild(e); | |
}()); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment