2

開発者のサイトで生成した facebook のようなボタンを追加しましたが、問題は、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>

各ページに同じカウンターを設定するにはどうすればよいですか?

4

1 に答える 1