好吧,我有一个非常直接的问题:如何在我的网站上显示来自Facebook评论社交插件的最新评论?
我已经在我的wordpress博客上集成了facebook评论社交插件,我只想在我的侧边栏上放一个小部件,显示社交插件最近的评论。
谢谢!
社交插件有一些更改布局的方法,但所有这些方法都允许用户编写新的注释。一种只获取评论的方法是通过FQL。
要使用它,请在你的代码中包含facebookall.js(我想你已经拥有了,一旦你使用了社交插件),并执行以下操作:
首先创建一个带有类"comments"的div:
<div class="comments"></div>
然后,在javascript 中执行以下操作
FB.api(
{
method: 'fql.query',
query: 'select text from comment where object_id in (select comments_fbid from link_stat where url ="http://developers.facebook.com/docs/reference/fql/comment/")'
},
function(response) {
$.each(response, function(i, e) {
$(".comments").append("<div class='comment'>"+e.text+"</div>");
});
}
);
如果您的div有一个不是注释的类,只需将$(".comments")
替换为$(".your-class")
即可。这段代码将在comments元素中创建几个带有类注释的元素。
我使用jQuery来迭代注释。
希望它能有所帮助!
您可以使用此小部件在您选择的小部件区域显示最近在您的网站上发表的Facebook评论。https://www.heateor.com/facebook-comments-moderation