A simple question about facebook comments plugin

♀尐吖头ヾ 提交于 2019-12-04 10:04:55

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

Hi if you are having comment id then why you dont use FQL and query to Comment Table to get all comment related data?

I am having this same problem. What seems to be happening is that the commentID and parentCommentID are actually just returning the unique ID of that page, and not a unique ID for the comment itself.

The unique ID for an individual comment is the unique ID of the page (that is, the value currently being returned as "commentID") with an underscore followed by another number (8 digits long in the tests I've done). You can look this up directly from the graph the response provided it.

I have logged a bug with Facebook to hopefully get this fixed! Bug at address below:

http://bugs.developers.facebook.net/show_bug.cgi?id=16535

Hm. I can retreive comment data by id (id format like this: 1234567890123456_12345678). Ids i retreive from url like this: https://graph.facebook.com/comments?ids={$url}

I combined a couple approaches (including from Charsee).

// this query takes a "commentID" and "href". The commentID is returned on comment.create "response" object

// this code requires an escape function "addslashes(str)" to handle single quotes.

var query = "SELECT text, fromid FROM comment WHERE post_fbid='"+addslashes(commentID)+"' AND ( object_id in (select comments_fbid from link_stat where url ='"+addslashes(href)+"') or object_id in (select post_fbid from comment where object_id in (select comments_fbid from link_stat where url ='"+addslashes(href)+"')))";

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!