How to display recent comments from Facebook Comments social plugin?

前端 未结 2 931
甜味超标
甜味超标 2021-01-05 16:49

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 com

相关标签:
2条回答
  • 2021-01-05 17:21

    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!

    0 讨论(0)
  • 2021-01-05 17:29

    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

    0 讨论(0)
提交回复
热议问题