Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A simple question about facebook comments plugin

I'm struggling with a very simple problem. The facebook documentation, as always, didn't give me enough explanation.

I attached a facebook comments plugin to my site. And using a callback of "comment.create" event, I can get information of a just-create comment.

FB.Event.subscribe('comment.create', function(response) {
    alert(JSON.stringify(response));
});

The json reponse looks like:

{"href":"http://siteaddress.com/page.htm", "commentID":"111122223333" }

What I like to do now is to retrieve the data of the single comment with the commentID. Although I expected that the following way should work:

https://graph.facebook.com/111122223333

it just gave me "False". I can retrieve all comments attached to that page using:

https://graph.facebook.com/comments?ids=http://siteaddress.com/page.htm

But, what is the right way to retrieve the single comment data just created using the commentID?

like image 210
HyoGi Sim Avatar asked Jan 20 '23 04:01

HyoGi Sim


1 Answers

I was also facing the same problem... so what i did was , I queried the last posted comment or reply from the fb comments table using fql. Here I sort the comments by time in descending order and pick the top one. though one may think that if two comments are posted at same time, it may cause ambiguity, But in my case i tried and tested it invoving more than 2 users but i always got the expected result.

FB.Event.subscribe('comment.create', function(response) {
    FB.api({
        method: 'fql.query',
        query: "select post_fbid, fromid, object_id, text, time from comment where object_id in (select comments_fbid from link_stat where url ='URL_OF_THE_COMMENT_BOX') or object_id in (select post_fbid from comment where object_id in (select comments_fbid from link_stat where url ='URL_OF_THE_COMMENT_BOX')) order by time desc limit 1"
      },
      function(response) {
        var feed = response[0];
        alert(feed.text)
      }
    );
  });  
like image 123
Wasim Avatar answered Feb 12 '23 17:02

Wasim