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