简体   繁体   中英

How to display recent comments from Facebook Comments social plugin?

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!

You can use this widget to show recent Facebook Comments made all over your website in the widget area of your choice. https://www.heateor.com/facebook-comments-moderation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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