Hyo*_*Sim 4 comments facebook graph
我正在努力解决一个非常简单的问题.facebook文档一如既往,没有给我足够的解释.
我在我的网站上附上了一条facebook评论插件.并使用"comment.create"事件的回调,我可以获得刚创建注释的信息.
FB.Event.subscribe('comment.create', function(response) {
alert(JSON.stringify(response));
});
Run Code Online (Sandbox Code Playgroud)
json响应看起来像:
{"href":"http://siteaddress.com/page.htm", "commentID":"111122223333" }
Run Code Online (Sandbox Code Playgroud)
我现在要做的是使用commentID检索单个注释的数据.虽然我希望以下方式可行:
https://graph.facebook.com/111122223333
Run Code Online (Sandbox Code Playgroud)
它只是给了我"假".我可以使用以下方法检索附加到该页面的所有评论
https://graph.facebook.com/comments?ids=http://siteaddress.com/page.htm
Run Code Online (Sandbox Code Playgroud)
但是,检索刚使用commentID创建的单个注释数据的正确方法是什么?
我也遇到了同样的问题...所以我做的是,我查询了最后发表的评论或使用fql从fb评论表回复.在这里,我按时间按降序对评论进行排序,然后选择最顶层的评论.虽然有人可能认为如果同时发布两条评论,可能会引起歧义,但在我的情况下,我尝试并测试了它,但是我总是得到预期的结果.
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)
}
);
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2936 次 |
最近记录: |