2

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

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

开发工具包:

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>

我怎样才能为每个页面设置相同的计数器?

4

1 回答 1

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 ???

于 2013-04-02T12:37:32.540 回答