fmchan
fmchan

Reputation: 760

Get Data from Facebook Comment Plugin

I learnt the way to build a comment plugin by copying the codes from https://developers.facebook.com/docs/plugins/comments/

I would like to know are there any ways to retrieve comments while users sending Facebook comments. i.e., send a comment to store in both Facebook database and my local database.

Upvotes: 0

Views: 796

Answers (1)

feijones
feijones

Reputation: 63

After some reading at this link, in the FAQ section:

How do I know when someone commented on my site?

You can subscribe to the 'comment.create' and 'comment.remove' events in the Facebook SDK for JavaScript through FB.Event.subscribe.

code:

// In your HTML, include the comments plugin
<div
  class="fb-comments"
  data-href="http://url.to.your-page/page.html"
  data-numposts="5"
  data-colorscheme="light">
</div>

// In your onload method
FB.Event.subscribe('comment.create', comment_callback);
FB.Event.subscribe('comment.remove', comment_callback);

// In your JavaScript
var comment_callback = function(response) {
  console.log("comment_callback");
  console.log(response);
}

Upvotes: 1

Related Questions