【问题标题】:How can I get the facebook comment that was just created如何获取刚刚创建的 facebook 评论
【发布时间】:2012-05-29 08:49:02
【问题描述】:

我的页面上有一个 fb 评论插件。当有人使用它发表评论时,有没有办法取回评论文本?

感谢任何可以提供帮助的人。

【问题讨论】:

  • 你不能只用一个插件来做到这一点。您必须使用一些额外的代码来实现这一点,使用 SDK 会更容易......

标签: javascript jquery facebook facebook-graph-api facebook-comments


【解决方案1】:

查看 Facebook Javascript SDK 中的 FB.Event.subscribe 方法。有一个名为comment.create 的事件,使用此代码您可以找到新评论:

FB.Event.subscribe('comment.create', function(post) {
    FB.api({
        method: 'fql.query',
        query: 'SELECT text, post_fbid FROM comment WHERE object_id IN (SELECT comments_fbid FROM link_stat WHERE url = "' + post.href + '")'
    }, function(comments) {
        /* Iterate through the all comments for this url */
        for (var i = 0; i < comments.length; i++) {
            /* Find the created comment text by its ID */
            if (comments[i].post_fbid == post.commentID) alert(comments[i].text);
        }
    });
});

【讨论】:

    【解决方案2】:

    您可以像这样使用 Facebook 的 FQL:SELECT text FROM comment WHERE object_id IN (SELECT comments_fbid FROM link_stat WHERE url = 'YOUR_COMMENT_URL')

    阅读更多here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-04
      • 1970-01-01
      • 2017-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-09
      • 1970-01-01
      相关资源
      最近更新 更多