如何显示Facebook的评论社交插件? [英] How to display recent comments from Facebook Comments social plugin?

查看:161
本文介绍了如何显示Facebook的评论社交插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯,我只是一个很直截了当的问题:
我如何显示Facebook的评论社交插件在我的网站?



我已经集成Facebook在我的wordpress博客上评论社交插件,我只是想在我的侧边栏上放置一个小部件,显示社交插件的最新评论。



谢谢!

解决方案

社交插件有一些方法来更改其布局,但所有这些都将允许用户写一个新的注释。仅获得评论的一种方式是FQL。



要使用它,请在您的代码中包含facebook all.js(我猜你有,一旦你使用社交插件),并执行以下操作: / p>

首先用类'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其中url =http://developers.facebook.com/docs/reference/fql/comment/)'
},
函数(响应){

$。每个(response,function(i,e){
$(。comments)。append(< div class ='comment'>+ e.text +< / div>);
});

}
);

如果你的div有一个没有注释的类,只需替换 $ .comments) $(。your-class)。这个代码将在你的注释元素中创建几个含有类注释的元素。



我使用jQuery迭代注释。



希望它有帮助!


Well, I just have a pretty straight question: How do I display recent comments from Facebook Comments social plugin on my website?

I have integrated the facebook comments social plugin on my wordpress blog and I just want to put a widget on my sidebar that displays the recent comments from the social plugin.

Thanks!

解决方案

The social plugin has some ways to change its layout, but all of them will allow the user to write a new comment. One way to get only the comments is by FQL.

To use it, include the facebook all.js on your code (I guess you have it, once you're using the social plugin) and do the following:

First create a div with class 'comments':

<div class="comments"></div>

Then, do the following in 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>");
        });         

    }
);

If your div has a class that is not comments, just replace $(".comments") with $(".your-class"). This code will create several elements with class comment inside your comments element.

I'm using jQuery to iterate the comments.

Hope it helps!

这篇关于如何显示Facebook的评论社交插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆