Skip to content

Instantly share code, notes, and snippets.

@cjzopen
Last active November 9, 2018 01:16
Show Gist options
  • Save cjzopen/03d3b90bd0a43d76a94e15faf2560241 to your computer and use it in GitHub Desktop.
Save cjzopen/03d3b90bd0a43d76a94e15faf2560241 to your computer and use it in GitHub Desktop.
v3.2
<div id="all">
<div class="share_fb">click me to share.</div>
<br>
<br>
<br>
<div id="result"></div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{{ id }}',
xfbml : true,
version : 'v3.2'
});
FB.AppEvents.logPageView();
$(document).on('click','.share_fb',function(){
FB.ui({
method: 'share',
title: 'title Test',
description: 'to next step after share',
href: '{{ your webpage url }}',
},
function(response) {
if (response && !response.error_code) {
$('#result').text('share completed.')
} else {
$('#result').text('share failed.');
}
});
});
};
(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 = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment