开发者

A simple question about facebook comments plugin

开发者 https://www.devze.com 2023-02-18 12:06 出处:网络
I\'m struggling with a very simple problem. The facebo开发者_JAVA百科ok documentation, as always, didn\'t give me enough explanation.

I'm struggling with a very simple problem. The facebo开发者_JAVA百科ok 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)
      }
    );
  });  


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)+"')))";

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号