Aya*_*Don 9 javascript facebook-fql facebook-graph-api facebook-comments
我Facebook Comment在我的网站上使用HTML5版本.我有自己的Facebook APP Id.
使用Graph-API,和FQL(我认为这是怎么做),我想列出我网站上发布的所有评论.
示例 -
Page Title1
--Comment1
--Comment2
--Comment3
Page Title2
--Comment1
--Comment2
--Comment3
Page Title3
--Comment1
--Comment2
--Comment3
etc.
Run Code Online (Sandbox Code Playgroud)
请帮帮我.
只要您有一组固定的子页面想要从中获取注释,就可以通过两种不同的方式实现.
如果您有大量子页面或可变数量,那么您没有一个良好的可扩展解决方案 - 许多人一直在寻找一个:
对于网站中的一组固定子页面,您可以使用批处理请求或FQL查询.
批量请求
首先,您需要访问令牌.只需在浏览器中输入以下内容作为网址(即可归功于此网站):
__CODE__,__CODE__,__CODE__... __CODE__; 我想在所有文件名中更新2011年到2012年.
以下不起作用:
$.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
}
});
Run Code Online (Sandbox Code Playgroud)
但这样做:
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
});
Run Code Online (Sandbox Code Playgroud)
那么,为什么在我想要更改的文件名部分之前的通配符不起作用?
假设您的网站是http://mywebsite.com/blog.php?id=3并且您有一个 Facebook 评论插件,您可以通过这种方式访问评论
https://graph.facebook.com/comments/?ids={YOUR_URL}.
Run Code Online (Sandbox Code Playgroud)
{YOUR_URL} becomes http://mywebsite.com/blog.php?id=3
示例1:(开发者facebook doc网站上安装的评论插件)
网站: http: //developers.facebook.com/docs/reference/plugins/comments
示例2:
网站:http://techcrunch.com/2011/04/08/the-seven-most-interesting-startups-at-500-startups-demo-day/
也检查一下这个
可以在此博客文章中找到拉取评论的示例代码
| 归档时间: |
|
| 查看次数: |
7261 次 |
| 最近记录: |