单个页面上有多个 Facebook 评论框?
我在一个页面上列出了三个产品,我希望在每个产品的侧面添加一个小评论框,有点像: https://www.facebook.com/SanukFootwear?ref=ts&sk=app_113298085356151。主要问题是,我似乎不知道如何向页面添加多个评论框。
我尝试使用 HTML5 和 XFBML。我现在使用的代码是:
<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=MYAPPID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
和
似乎将 xid
添加到
块应该只为该 xid 生成唯一的评论列表。然而,这不起作用。如果我执行以下操作:
并尝试在其中一个上发帖,评论都会显示在两个上。我是否缺少某些东西来允许这些独特的评论?
sanuk 商店 Facebook 页面的代码是这样的:
<fb:comments xid="featured_product_56062795998_1" width="255" numposts="5" expr:href="##_1" class=" fb_iframe_widget">
<span>
<iframe id="f1f0d95ac" name="f341a4ded" scrolling="no" style="border-width: initial; border-color: initial; overflow-x: hidden; overflow-y: hidden; width: 255px; height: 572px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " class="fb_ltr" src="https://www.facebook.com/plugins/comments.php?api_key=113298085356151&channel_url=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D3%23cb%3Df5542ec34%26origin%3Dhttps%253A%252F%252Fnorthsocial.com%252Ff2d77af7ec%26relation%3Dparent.parent%26transport%3Dpostmessage&locale=en_US&numposts=5&sdk=joey&title=&url=https%3A%2F%2Fnorthsocial.com%2Fapp%2Ftab%2Ffeatured_products%2Fview.php&width=255&xid=featured_product_56062795998_1"></iframe>
</span>
</fb:comments>
我不知道他们从哪里获取此 iFrame 内容。我参考了facebook的开发文档,但一直找不到任何信息。任何帮助将不胜感激!
预先感谢,
特雷
I have three products listed on a single page and I'm looking to add a small comment box to the side of each of the products, kind of like : https://www.facebook.com/SanukFootwear?ref=ts&sk=app_113298085356151. The main problem is, I can't seem to figure out how to add more than one comment box to the page.
I tried using HTML5 and XFBML. The code I'm using now is :
<html xmlns:fb="http://ogp.me/ns/fb#">
<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=MYAPPID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
and
<fb:comments href="MYURL" num_posts="5" width="500" xid="product_01"></fb:comments>
It seems that adding xid
to the <fb:comments>
block is supposed to generate a unique list of comments for only that xid. This however is not working. If I do the following:
<fb:comments href="MYURL" num_posts="5" width="500" xid="product_01"></fb:comments>
<fb:comments href="MYURL" num_posts="5" width="500" xid="product_02"></fb:comments>
and try posting on either one, the comment shows up on both. Is there something I'm missing to allow these unique comments?
The code from the sanuk shop facebook pages is this:
<fb:comments xid="featured_product_56062795998_1" width="255" numposts="5" expr:href="##_1" class=" fb_iframe_widget">
<span>
<iframe id="f1f0d95ac" name="f341a4ded" scrolling="no" style="border-width: initial; border-color: initial; overflow-x: hidden; overflow-y: hidden; width: 255px; height: 572px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " class="fb_ltr" src="https://www.facebook.com/plugins/comments.php?api_key=113298085356151&channel_url=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D3%23cb%3Df5542ec34%26origin%3Dhttps%253A%252F%252Fnorthsocial.com%252Ff2d77af7ec%26relation%3Dparent.parent%26transport%3Dpostmessage&locale=en_US&numposts=5&sdk=joey&title=&url=https%3A%2F%2Fnorthsocial.com%2Fapp%2Ftab%2Ffeatured_products%2Fview.php&width=255&xid=featured_product_56062795998_1"></iframe>
</span>
</fb:comments>
I have no idea where they are getting this iFrame content from. I referred to the facebook development docs, but have been unable to find any information. Any help would be appreciated!
Thanks in advance,
Tre
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
评论插件没有我可以在以下位置看到的 xid 参数: https:// Developers.facebook.com/docs/reference/plugins/comments
您需要为每个评论框指定唯一的 URL
The comments plugin doesn't have a xid paramter that I can see at: https://developers.facebook.com/docs/reference/plugins/comments
You need to specify a unique URL for each of the comment boxes
我已经解决了我网站一页的多个评论框问题。这对我有用:
生成 FB 代码时,您必须输入“要评论的 URL”。对于第一个框,只需输入 url。对于第二个框,我添加了 mysite.com/#comments2。对于第三个框,我添加了 mysite.com/#comments3。等等。这应该为每个 URL 提供一个单独的评论框。希望这有帮助。
I have resolved multiple comments boxes issues for one page for my site. This is what worked for me:
When generating your FB code, you have to enter the "URL to comment on". For the first box, just enter the url. For second box I added mysite.com/#comments2. For third box I added mysite.com/#comments3. Etc, Etc. This should give you a separate comment box per URL. Hope this helps.
它仍然可以使用下面的代码。
It still working with below code.