I found a solution, but it’s not using the share button, but rather the api, the only triggered Response when the user actually shares it
<div class="page-header">
<h1>Share Dialog</h1>
</div>
<p>Click the button below to trigger a Share Dialog</p>
<div id="shareBtn" class="btn btn-success clearfix">Share</div>
<p style="margin-top: 50px">
<hr />
<a class="btn btn-small" href="https://developers.facebook.com/docs/sharing/reference/share-dialog">Share Dialog Documentation</a>
</p>
<script>
document.getElementById('shareBtn').onclick = function() {
FB.ui({
method: 'share',
display: 'popup',
href: 'https://developers.facebook.com/docs/',
}, function(response){
if(response.post_id !== 'undefined'){
alert('foi postado');
}
});
}
</script>
Here you can test the code
Here you have more api info
Here is the load you need to put to use the facebook sdk
// Load the SDK asynchronously
(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'));
Still for the SDK you need Create a Facebook App, have a tutorial here
What are you wearing? If you used the share button, it apparently doesn’t have https://developers.facebook.com/docs/plugins/share-button/, it even counts, but returns nothing(doesn’t have a callback function parameter)
– Rodrigo Jarouche