Facebook喜欢反击

时间:2013-04-02 12:12:42

标签: facebook facebook-like counter

我添加了我在开发者网站上生成的facebook like按钮,但问题是,当我更改我的url时,类似按钮计数器会发生变化:

url : http://localhost/ci/   --> 7 likes
url : http://localhost/ci/fr/--> 0 likes

SDK:

window.fbAsyncInit = function() {
        // init the FB JS SDK
        FB.init({
          appId      : 'xxx', // App ID from the App Dashboard
          channelUrl : 'http://localhost/ci', // Channel File for x-domain communication
          status     : true, // check the login status upon init?
          cookie     : true, // set sessions cookies to allow your server to access the session?
          xfbml      : true  // parse XFBML tags on this page?
        });

        // Additional initialization code such as adding Event Listeners goes here
      };

      // Load the SDK's source Asynchronously
      // Note that the debug version is being actively developed and might 
      // contain some type checks that are overly strict. 
      // Please report such bugs using the bugs tool.
      (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));

来自https://developers.facebook.com/docs/reference/plugins/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&appId=xxx";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

我如何为每个页面设置相同的计数器?

1 个答案:

答案 0 :(得分:0)

您还没有尝试过HTML标记吗?

<div class="fb-like" data-href="http://URL_SAME" data-send="true" data-width="450" data-show-faces="true"></div>

在data-href中使用相同的url ???

相关问题