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?
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)
}
);
});
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