6

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!

Raven
  • 2,187
  • 7
  • 35
  • 61

2 Answers2

3

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!

Raphael Petegrosso
  • 3,870
  • 2
  • 24
  • 27
  • Thanks dude! Well, I tried it and it works...It shows a popup dialog of the comment...(I don't know how to code JavaScript)..But how do I just make it to post the texts in a paragraph?....Another concern is that it only shows comments from a specific page of a domain and not on the entire domain with pages...(See Itnotes.tk)...thank you so much again dude! – Raven Jun 26 '11 at 13:26
  • I changed the answer a bit. About the entire domain, unfortunately I think it can't be done. – Raphael Petegrosso Jun 26 '11 at 13:55
  • 2
    It is impossible to get an entire domain's comments in a straight forward fashion. See the answer I posted here http://stackoverflow.com/a/10412716/280503 – gardenofwine May 02 '12 at 12:26
-3

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

Rajat Varlani
  • 456
  • 1
  • 4
  • 19