根据 the Facebook documentation , comment.create
回调包含 Comment ID 属性:
{
href: "", /* Open Graph URL of the Comment Plugin */
commentID: "", /* The commentID of the new comment */
}
但是我看到回调包含一个公共(public) 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"
}
有谁知道如何通过 comment.create 事件获得完整的标识符?或者是否有另一个字段可用于预测 commonid_commentID
格式?
最佳答案
回调中的评论 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);
});
});
关于javascript - Facebook Comments.Create 回调中的 ID 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7181315/