javascript - Facebook like and share button with callback -


i have webpage have placed facebook & share button , corresponding javascript callback functions present.

now problem is, javascript callback fires when user 'likes' , doesn't seem fire when 'share' button pressed.

its need award user everytime he/she shares link. whereas 'like', user can link once (not considering unlike/re-like).

i know share button deprecated. facebook provides share button button. source : https://developers.facebook.com/docs/plugins/like-button/

is there way fire callback method share button?

here's code :

code @ beginning of body tag in html :-

<div id="fb-root"></div>  <script>     window.fbasyncinit = function() {     fb.init({         appid: ' app id ',         status: true,         cookie: true,         xfbml: true,         oauth: true     });     fb.event.subscribe('edge.create', function(response) {         alert('you liked url: ' + response);        }); }; (function(d) {     var js, id = 'facebook-jssdk';     if (d.getelementbyid(id)) {         return;     }     js = d.createelement('script');     js.id = id;     js.async = true;     js.src = "//connect.facebook.net/en_us/all.js";     d.getelementsbytagname('head')[0].appendchild(js); }(document));          </script> 

code display & share buttons:-

<div class="fb-like" data-href=" url " data-layout="button_count" data-action="like" data-show-faces="false" data-share="true"></div> 

you cannot share callback using button. can instead create share button of yours , invoke feed dialog on click-

fb.ui( {   method: 'feed',   name: 'facebook dialogs',   link: 'https://developers.facebook.com/docs/dialogs/',   picture: 'http://fbrell.com/f8.jpg',   caption: 'reference documentation',   description: 'dialogs provide simple, consistent interface applications interface users.' }, function(response) {   if (response && response.post_id) {     alert('post published.');   } else {     alert('post not published.');   } } ); 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -