简体   繁体   English

在移动和桌面网站之间同步Facebook评论

[英]Sync Facebook Comments between Mobile and Desktop website

I have 2 versions of my website Mobile and Desktop with Facebook Comment Plugin embedded in it. 我的网站“ 移动”和“ 桌面”有2个版本,其中嵌入了Facebook Comment Plugin I want to sync every comment between the 2 websites having same address except for the subdomain like 我想在地址相同的2个网站之间同步每个评论,但子域名除外

https://www.example.com/contact-us.php
https://m.example.com/contact-us.php

I read about Comment Mirroring at Facebook Comments - Synchronization between website and fan page but I don't think this is what I want. 我在Facebook评论上阅读了有关Comment Mirroring -网站和粉丝页面之间的同步,但我认为这不是我想要的。

I want to enable my visitors to comment and see same comments on both these versions. 我想让我的访客评论这两个版本并看到相同的评论。 Is it possible or not? 有没有可能? I mean if someone comment on desktop version website then the comment should be visible on mobile version as well. 我的意思是,如果有人在桌面版网站上发表评论,那么评论也应该在移动版上可见。

I have this code provided by Facebook when embedding Comment Plugin. 嵌入评论插件时,我有Facebook提供的这段代码。 Where do I have to change to support comment sync 我必须在哪里更改以支持评论同步

 <div id="fb-root"></div>
 <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/sdk.js#xfbml=1&version=v2.6&appId=XXXXXXXXXXXXXXXX";
 fjs.parentNode.insertBefore(js, fjs);
 }(document, \'script\', \'facebook-jssdk\'));</script>

And this code on the page I want to show comment block 我想在页面上显示此代码的注释块

 <div class="fb-comments" data-href="https://www.example.com/contact-us.php" data-width="950" data-numposts="5"></div>

The comments made via the comments plugin are not tied to the page that you embed the plugin on, but to the URL you specify in the data-href parameter. 通过评论插件所做的评论并不与您嵌入插件的页面相关,而是与您在data-href参数中指定的URL相关。

So if you want to have the same comments on the desktop and the mobile version of your site - specify one of those URLs as data-href for both versions. 因此,如果您想在桌面版和网站的移动版上发表相同的评论,请为这两个版本指定其中一个URL作为数据引用。


Also, you should use the same og:url value for both versions; 另外,两个版本都应使用相同的og:url值; otherwise, like and share counts will get split over those two distinct URLs. 否则,“喜欢”和“分享”计数将分配给这两个不同的URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM