Facebook评论在每个页面上都是重复的

时间:2011-12-29 17:56:43

标签: facebook comments

我正在尝试将Facebook评论整合到我的网站中(我几个月前尝试过这样做,但似乎没有多少支持,我无法理解它)。评论显示,我设法得到评论显示在我的Facebook墙上的个人帖子/项目,但不幸的是,它在每个帖子下张贴相同的评论。您可以在此处看到此框:http://www.roomfor5.co.uk/item/6726

该网站基于PHP,我使用的代码是:“title =”“url =”“width =”600“publish =”true“>

我也使用此代码但没有成功:“width =”600“publish =”true“>

我知道这与xid属性有关,但我很难过为什么它会重复:(

2 个答案:

答案 0 :(得分:1)

您好,在查看您网页的观看源时,我看到了这一点:

<fb:comments 
   xid="http://www.roomfor5.co.uk-<?=str_replace('/','-',$_SERVER['REQUEST_URI']);?>" 
   num_posts="2" 
   width="600" 
   publish="true" >
</fb:comments>

所以fb:comments标签没有完全渲染出来。

同样在呈现的页面上,它表示您尚未指定网址。虽然有一个格式错误的xid =属性,但你真的应该有一个url =属性。见https://developers.facebook.com/docs/reference/plugins/comments/

Warning: this comments plugin is operating in 
compatibility mode, but has no posts yet. 
Consider specifying an explicit 'href' as 
suggested in the comments plugin documentation 
to take advantage of all plugin features.

修改 对于http://www.roomfor5.co.uk/item/6726,您有

<div 
  class="fb-comments" 
  data-href="http://www.roomfor5.co.uk" 
  data-num-posts="5" 
  data-width="600">
</div>

data-href属性应为http://www.roomfor5.co.uk/item/6726而不是http://www.roomfor5.co.uk

答案 1 :(得分:0)

如果点击“查看来源”,您会看到呈现的HTML:

<fb:comments xid="http://www.roomfor5.co.uk-<?=str_replace('/','-',$_SERVER['REQUEST_URI']);?>" num_posts="2" width="600" publish="true" >

看起来您正在尝试为页面指定唯一的xid,但服务器端脚本的行为与纯文本类似。