如何修复这个像Facebook的按钮

时间:2011-06-08 12:12:20

标签: facebook facebook-like

当我点击我博客上某个帖子上的facebook like按钮时,它会在我博客上的每个帖子上注册一个“赞”。我试图得到它,如果我点击帖子上的“喜欢”,它只适用于该帖子。

你看到我做错了吗?如果你能

,谢谢你的帮助

这是我的html标签

<html xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">

这是在我的标题中。注意,它在这里说“example.com”,这只是因为我不想发布我的实际域名。在我的网站上,我使用我的真实域名

<meta property="og:title" content="My example website"/>
<meta property="og:site_name" content="my example website"/>
<meta property="og:image" content="http://example.com/2011/pic-of-your-mama/"/>
<meta property="fb:app_id" content="app id"/>
<meta property="fb:admins" content="my facebook id"/>

这是在我的身体标签

之后
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId  : 'myfacebookid',
      status : true, // check login status
      cookie : true, // enable cookies to allow the server to access the session
      xfbml  : true  // parse XFBML
    });
  };

  (function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

这就是我对实际按钮的看法

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=myappid&amp;xfbml=1"></script><fb:like href="http://example.com" send="true" width="450" show_faces="false" font="arial"></fb:like>

2 个答案:

答案 0 :(得分:1)

在按钮中有:

  

<fb:like href="http://example.com"

我想你忘记在那里设置一个正确的URL(可能是你喜欢的博客网址)。

答案 1 :(得分:0)

我不确定您使用的博客平台,但如果您使用的是Blogger,则可以将此属性expr:href='data:post.url'放入fb:like标记中。 expr前缀将根据博客数据分析报价中的值。

很自然,你的Facebook喜欢标签就像<fb:like expr:href='data:post.url' send='true' show_faces='true' width='450'/>

相关问题