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

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

问题描述

我在我的网站上使用HTML5版本的 Facebook Comment 。我有自己的Facebook APP Id。



使用 Graph-API FQL (我想这是怎么做的),我想列出我网站上发布的所有评论。



示例 -

 页面标题1 
--Comment1
--Comment2
--Comment3

页面Title2
--Comment1
--Comment2
--Comment3

页面标题3
--Comment1
--Comment2
--Comment3


请帮助我。 / p>

解决方案

只要您有一个固定子集,就有两种不同的方式要从其中提取评论的页面。



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





对于您网站中的固定子页面集,您可以使用批处理请求或FQL查询。



批量请求






首先,您需要访问令牌。只需在浏览器中输入以下内容作为url(信用于这个网站):




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



这是一个javascript jquery代码,用于进行批处理请求以从多个URL一次性获取注释:

 $。ajax({
url:'https://graph.facebook.com/',
type:POST ,
data:{
access_token:'YOUR_APP_ACCESS_TOKEN',
batch:'[\
{method:GET,ative_url:URL1} ,\
{method:GET,relative_url:URL2} \
]'
},
success:function(d ata){
jdata = JSON.parse(data);
$ .each(jdata,function(index,value){
jdata [index] .body = JSON.parse(value.body);
console.log(value.body);
});
//用jdata
}
}做任何你想要的任何事情;

FQL



< hr>

灵感来源于这个帖子

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






结论 p>

由于Facebook的这种限制,我打算切换到disqus.com,这显然支持这个功能(从这个 blog ,(搜索最近评论)


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

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

Example -

Page Title1
--Comment1
--Comment2
--Comment3

Page Title2
--Comment1
--Comment2
--Comment3

Page Title3
--Comment1
--Comment2
--Comment3

etc.

Please help me out.

解决方案

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:

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

Batch Request


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

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


inspired from this post

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


Conclusion

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天全站免登陆