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!
Tap in the top right of Facebook, then tap your name. Tap below your profile picture, then tap Activity Log. Tap Filter at the top of your activity log to review activities like: Things you've posted.
Click the “Add New Widget” button. Click on the “Facebook Comments” box. Name your widget by filling in the “Widget Name” field. Choose whether you would like customers to comment on the “Current Website Page” that they are on or a “Custom URL”.
Visit your Facebook profile or page. Click the dropdown button at the top-right corner and go to Settings & privacy > Settings. Under Settings, go to “Public Posts” in the sidebar on the left. Scroll down the page and click the 'Edit' button next to “Comment Ranking”.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With