I have a single fb comment plugin on my page. When someone posts a comment using it, is there a way to get the comment text back?
Thanks to anyone who can help.
I have a single fb comment plugin on my page. When someone posts a comment using it, is there a way to get the comment text back?
Thanks to anyone who can help.
Check out the FB.Event.subscribe
method in the Facebook Javascript SDK. There is an event called comment.create
and with this code you can find the new comment:
FB.Event.subscribe('comment.create', function(post) {
FB.api({
method: 'fql.query',
query: 'SELECT text, post_fbid FROM comment WHERE object_id IN (SELECT comments_fbid FROM link_stat WHERE url = "' + post.href + '")'
}, function(comments) {
/* Iterate through the all comments for this url */
for (var i = 0; i < comments.length; i++) {
/* Find the created comment text by its ID */
if (comments[i].post_fbid == post.commentID) alert(comments[i].text);
}
});
});