Create a gist now

Instantly share code, notes, and snippets.

@Nodws /embed
Created Aug 8, 2014

What would you like to do?
Embed Facebook Comments from given post ID
function initFbEmbedPosts(){
jQuery('.embed-fb-comments').each(function(i,e){
var comment = jQuery(e);
var postId = comment.attr('data-post-id');
//you will need the div with attribute data-post-id
//You can also make this get the ID from the fb embed post element
jQuery.getJSON('https://graph.facebook.com/'+ postId +'/comments', null, function(data){
for (obj in data.data) {
var item = data.data[obj];
var itemRow = wddFbMakeCommentRow(item);
comment.append( itemRow );
}
});
});
};
function wddFbMakeCommentRow(object){
var row = '<div class="UFIRow clearfix">'+ "\n" +
'<div class="ufithumbwrap">'+ "\n" +
' <a href="http://facebook.com/profile.php?id='+ object.from.id +'" class="ufithumblnk">'+ "\n" +
' <img class="ufithumb" src="http://graph.facebook.com/'+ object.from.id +'/picture?type=square" />'+ "\n" +
' </a>'+ "\n" +
'</div>'+ "\n" +
'<div>'+ "\n" +
' <div class="clearfix UFIImageBlockContent ">'+ "\n" +
' <div class="UFICommentContentBlock">'+ "\n" +
' <div class="UFICommentContent">'+ "\n" +
' <a href="http://facebook.com/profile.php?id='+ object.from.id +'" class="UFICommentActorName">'+ "\n" +
object.from.name + "\n" +
' </a>'+ "\n" +
' <span class="UFICommentBody">'+ "\n" +
object.message + "\n"
' </span>'+ "\n" +
' </div>'+ "\n" +
' </div>'+ "\n" +
' </div>'+ "\n" +
'</div>'+ "\n" +
'<div class="clearfix"></div>'+ "\n" +
'</div>';
return row;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment