Facebook fb:评论Graph API [英] Facebook fb:comments Graph API
问题描述
我想在我的网站上有Facebook评论+我自己的网站评论。
事情是在显示帖子时,我想显示每个单独的评论数一个(所以我的评论+ Facebook的意见)。
我知道我可以通过 https://graph.facebook.com/comments/ ?ids = {PAGE_URL}但是我每页都有100个页面,我不想每页都执行100次查询,更重要的是我想创建一个最有评论的小部件,我目前有所以基本上我的问题是我可以访问我的域/站点上留下的所有评论的数据库排序和排序他们是操纵他们?
以下是一些可以做到这一点的例子:
FQL:
您可以构建一个JSON数组的查询,然后使用Rest API fql.multiquery方法来运行它们。例如,这将是您的JSON数组查询:
{
'query1':从评论中选择post_fbid其中object_id in(select comments_fbid from link_stat where url ='http://developers.facebook.com/docs/reference/fql/comment/'),
'query2':select comment_fbid from comment where object_id in (select links_fbid from link_stat where url ='http://developers.facebook.com/docs/reference/fql/album/')
}
使用测试控制台在 fql.multiquery页面,您将能够看到一个包含post_fbids列表的响应,然后您可以使用您喜欢的计数方法计数。
Graph API:
这里您可以使用批次请求一次运行所有查询。所以对于您要做的PHP示例:
curl \
-F'access_token = ...'\\ \\
-F'batch = [\
{method:GET,relative_url:comments /?ids = {PAGE_URL1}},\
{方法:GET,ative_url:comments /?ids = {PAGE_URL2}},\
{method:GET,ative_url:comments /?ids = {PAGE_URL3 }} \
]'\
https://graph.facebook.com
对于所需的页面数量。
注意:鉴于这两个API都有一点延迟才能得到响应,显然建议异步运行以便您不会导致您的站点负载显着延迟。
i want to have facebook comments + my own website comments on my site.
The thing is when showing posts i want to show a comment count next to every single one(so my comments + facebook comments). I know i can achieve this with https://graph.facebook.com/comments/?ids={PAGE_URL} but i have 100posts per page and i don't want to do this query a 100 times per page, also and more important is that i want to create a most commented widget where i currently have 1/4 of a million (250000) posts.
So basically my question is how i can access sort of a database on all comments left on my domain/site and sort them, that is manipulate them?
Here are some examples of ways you could do this:
FQL:
You can build your a JSON array of queries and then use the Rest API fql.multiquery method to run them. For example, this would be your JSON array of queries:
{
'query1': "select post_fbid from comment where object_id in (select comments_fbid from link_stat where url ='http://developers.facebook.com/docs/reference/fql/comment/')",
'query2': "select post_fbid from comment where object_id in (select comments_fbid from link_stat where url ='http://developers.facebook.com/docs/reference/fql/album/')"
}
Run this using the test console on the fql.multiquery page and you'll be able to see a response containing a list of post_fbids which you could then count using your favored counting method.
Graph API:
Here you can use a Batch Request to run all of your queries at once. So for a PHP Example you'd be doing:
curl \
–F ‘access_token=…’ \
-F ‘batch=[ \
{"method": "GET", "relative_url": "comments/?ids={PAGE_URL1}"}, \
{"method": "GET", "relative_url": "comments/?ids={PAGE_URL2}"}, \
{"method": "GET", "relative_url": "comments/?ids={PAGE_URL3}"} \
]’\
https://graph.facebook.com
For as many pages as you want.
Note: Given that both APIs do have a bit of a delay before you'll get a response, obviously it's recommended to run them asynchronously so that you aren't causing your site load to delay significantly.
这篇关于Facebook fb:评论Graph API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!