Can we get a callback response from facebook share dialogue box?
I have created a custom share button and trying to get the response from there. But its giving me a success response on clicking cancel button also in share dialogue
<script>
window.fbAsyncInit = function(){
FB.init({
appId: '782351051797017', status: true, cookie: true, xfbml: true });
};
(function(d, debug){var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];if (d.getElementById(id)) {return;}js = d.createElement('script'); js.id = id; js.async = true;js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";ref.parentNode.insertBefore(js, ref);}(document, /*debug*/ false));
function postToFeed(title, desc, url, image){
var obj = {
method: 'feed',
link: url,
picture: 'http://www.url.com/images/'+image,
name: title,
description: desc
};
function callback(response){
console.log('test');
}
FB.ui(obj, callback);
}
</script>
<a href="" data-image="article-1.jpg" data-title="Article Title" data-desc="Some description for this article" id="btnShare">Share</a>
<script>
$('#btnShare').click(function(){
elem = $(this);
postToFeed(elem.data('title'), elem.data('desc'), elem.prop('href'), elem.data('image'));
return false;
});
</script>
got the solution,i just had to read the response
function callback(response){
if(response==null){
console.log('test1');
}
else{
console.log('test2');
}
}
FB.ui(obj, callback);