Search code examples
asp.netfacebookfacebook-likefacebook-c#-sdk

fb-like some time get disappeared with fb-share plugin?


Here I am working with asp.net web application, I am using 2 facebook plugin in my web page.

  1. Facebook like
  2. Facebook share

For facebook share :

<a name="fb_share" type="button" share_url="*******"></a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript">
</script>

For facebook like :

 <script>    
    (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/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
    } (document, 'script', 'facebook-jssdk'));
 </script>

<div id="fb-root"></div>            
<div class="fb-like" data-href="********" data-send="false" 
  data-layout="button_count" data-width="10" 
  data-show-faces="false" style="width:45px; height:20px;"></div>

Case 1. above code work fine when I am using single code.

Case 2 : when I am using both some time facebook like plugin disappeared from page.

Thanks in advance...


Solution

  • Like button and Share button may be used on one page only if you avoid usage of javascript provided with it and use direct link to share.php (which I will not provide for reasons outlined bellow).

    If you'll use http://static.ak.fbcdn.net/connect.php/js/FB.Share it will break either Share or Like buttons, according to order of javascript inclusion, first one will work, second one is in trouble.

    Couple of points to take into consideration:

    • Share button is deprecated please avoid using it!

      The Share button has been deprecated in favor of the Like button, and will no longer be supported.

    • Share button can be easily replaced with usage of Feed Dialog and JS-SDK, which provide more control over sharing functionality:
      FB.ui({method: 'feed', link: document.location.href});