如何列出我域中的所有评论 [英] How to list all comments in my domain

查看:24
本文介绍了如何列出我域中的所有评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站中使用 Facebook Comment 的 HTML5 版本.我有自己的 Facebook APP ID.

I am using the HTML5 version of Facebook Comment in my website. I have my own Facebook APP Id.

使用Graph-APIFQL(我认为这是怎么做的),我想列出我网站上发布的所有评论.

Using Graph-API, and FQL (I think this is how to do it), I want to list all the Comments posted in my website.

示例 -

Page Title1
--Comment1
--Comment2
--Comment3

Page Title2
--Comment1
--Comment2
--Comment3

Page Title3
--Comment1
--Comment2
--Comment3

etc.

请帮帮我.

推荐答案

可以通过两种不同的方式,只要您有一组固定的子页面来获取评论从.

It is possible, in two different ways, as long as you have a fixed set of sub-pages you want to fetch comments from.

如果您有大量的子页面,或者数量可变,那么您就没有一个很好的可扩展解决方案 - 许多人一直在寻找一个:

If you have a large amount of sub-pages, or a variable amount, then you don't have a good scalable solution - and many have been looking for one:

对于您网站中的一组固定子页面,您可以使用批量请求或 FQL 查询.

For a Fixed set of sub-pages in your website, you can either use a batch request, or an FQL query.

批量请求

首先,您需要访问令牌.只需在浏览器中输入以下 URL(归功于 这个 网站 ):

First, you need your access token. Just enter the following as a url in a browser (credit to this website ):

<代码>https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=APP_ID&client_secret=APP_SECRET<代码>

这是 javascript jquery 代码,用于发出批处理请求以一次从多个 url 获取评论:

And this is the javascript jquery code to make a batch request to fetch comments from several urls at once:

$.ajax({
  url: 'https://graph.facebook.com/',
  type : "POST",
  data: {
    access_token : 'YOUR_APP_ACCESS_TOKEN',
    batch : '[ 
    {"method":"GET","relative_url":"URL1"}, 
    {"method":"GET","relative_url":"URL2"} 
    ]'
  },
  success: function(data) {
    jdata = JSON.parse(data);
    $.each(jdata, function(index,value){
        jdata[index].body = JSON.parse(value.body);
        console.log(value.body);
    });
    // Do whatever you want with jdata
  }
});

FQL

灵感来自这篇帖子

FB.api({
    method: 'fql.query',
    query: 'select text from comment where object_id in (select comments_fbid from link_stat where url="URL1" or url="URL2")'
  }, function(response) {
    // Do something with results
  });

<小时>

结论

因为Facebook的这个限制,我打算切换到disqus.com,它显然支持这个功能(从这个可以看出博客.(搜索最近的评论")

Because of this limitation of Facebook, I plan to switch to disqus.com, which apparently supports this feature (As you can see from this blog, for example. (search for 'recent comments')

这篇关于如何列出我域中的所有评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆