Facebook评论中的ID值.创建回调

fri*_*gon 4 javascript plugins comments facebook facebook-javascript-sdk

根据Facebook文档,comment.create回调包含一个Comment ID属性:

{
  href: "",         /* Open Graph URL of the Comment Plugin */
  commentID: "",    /* The commentID of the new comment */
}
Run Code Online (Sandbox Code Playgroud)

但是我发现回调包含一个不会在注释中更改的公共ID属性.例如,当我调试回调时,我得到一个commentID"10150259852273822",但该值不会因该页面上留下的任何注释而改变.下面是来自Graph API的注释的示例,注意多个注释中的ID是相同的,但是它附加了一个"_XXXX"看起来实际上是标识符的数字.

 {
    "id": "10150259852273822_17973898",
    "from": {
       "name": "XXXXXX",
       "id": "XXXXX"
    },
    "message": "newest comment",
    "created_time": "2011-08-24T19:24:02+0000"
 },
 {
    "id": "**10150259852273822**_17973932",
    "from": {
       "name": "XXXXX",
       "id": "XXXXX"
    },
    "message": "brand newest comment.",
    "created_time": "2011-08-24T19:25:40+0000"
 }
Run Code Online (Sandbox Code Playgroud)

有谁知道如何通过comment.create事件实际获得完整的标识符?或者是否有另一个字段可用于预测commonid_commentID格式?

Oli*_*ier 5

回调中的注释ID实际上是"post_fbid".以下是如何获取注释(以及与之关联的数据):

FB.Event.subscribe('comment.create', function(response) {
    var commentQuery = FB.Data.query("SELECT text, fromid FROM comment WHERE post_fbid='"+response.commentID+"' AND object_id IN (SELECT comments_fbid FROM link_stat WHERE url='"+response.href+"')");
    var userQuery = FB.Data.query("SELECT name, uid FROM user WHERE uid in (select fromid from {0})", commentQuery);

    FB.Data.waitOn([commentQuery, userQuery], function() {
        // Do whatever you want with the data
        console.log(commentQuery.value[0].text);
        console.log(userQuery.value[0].name)
        console.log(userQuery.value[0].uid);
    });
});
Run Code Online (Sandbox Code Playgroud)