I want to update my database when user share post on fb. I am using Facebook SDK for JAVASCRIPT.
My Code Is:-
<script>
document.getElementById('shareBtn').onclick = function() {
FB.ui({
method: 'share',
display: 'popup',
href: 'url goes here',
}, function(response){
if (response && response.post_id) {
//ajax code goes here for database update
} else {
alert('oops post was not published');
}
});
}
</script>
Button Code-
<div class="fb-share-button"
data-href="url goes here"
data-layout="button" data-size="large">
</div>
I am able to share the post but how to update the mysql data when user successfully sharesthe post