0

次のようなさまざまなページがあります。

www.mysite/directory/title?title=$title

したがって、各ページが動的になることがわかります。動的URL用にFacebookのようなボタンを生成したい前に何度も尋ねられました。昨年末に「いいね!」ボタンにいくつかの変更があったことに気がついたので、これに関する最近の投稿を探していました。

私が抱えている問題は、絶対URLが必要であると述べているFacebookエラーか、Facebookで設定されているもの、この場合は私のログインページへのいいねボタンを単に参照することです。

私は次のことを試しました:

    // 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));
</script>

    <script type="text/javascript">
      var sUrl = "http://www.mysite.com/";
      document.getElementById('fb').setAttribute('href', sUrl);
    </script>  
<div class="fb-like" id="fb"  data-send="true" data-layout="button_count" data-width="60" data-show-faces="true"></div>

と:

<?php $url = basename($_SERVER['REQUEST_URI']);?>
<div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true"></div>

一緒に:

  <div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=186609524720286&amp;xfbml=1"></script>
<div id="fblikeblock"></div>
<script>
    var url = 'http://apps.facebook.com/inflatableicons/image_preview.html?y=120';
    jQuery("#fblikeblock").html('<fb:like id="fbLike" href="'+url+'" send="true" width="450" show_faces="true" font=""></fb:like>');
    FB.XFBML.parse(document.getElementById('fblikeblock'));
    console.log(document.getElementById('fblikeblock'));
  </script>

そして忘れないでください:

<fb:like></fb:like>

FB.XFBML.parse を呼び出した後。

私は成功していませんが、ご覧のとおり、多くの方法で試してみましたが、かなり行き詰まっています。何か案は?

ありがとう!

編集:

URLはエンコードされているため、今日は次のことを試しましたが、結果は同じです。私がスタックを見たところはどこでも、これらの方法のいずれかが機能するはずであると述べていますが、どこにも行きません:

<div class="fb-like" id="fb" data-href="<?php urlencode($url);?>" data-send="true" data-width="450" data-show-faces="true"></div>

何か案は?

4

1 に答える 1

0

like url には data-href を使用します。 https://developers.facebook.com/docs/reference/plugins/like/

于 2013-02-17T00:51:08.863 に答える