从Facebook页面检索帖子和评论 [英] Retrieving posts and comments from a Facebook page

查看:193
本文介绍了从Facebook页面检索帖子和评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我写了这段代码(应用程序详细信息被混淆,用你自己的代替)为了运行它)。

 <?php 
require_once('facebook.php');
$ facebook = new Facebook(array(
'appId'=>'MY_APP_ID',
'secret'=>'MY_APP_SECRET',
'cookie'=>真,
));

$ pages = array(
stackoverflow=> 11239244970
);

$ result = $ facebook-> api(array(
'method'=>'fql.multiquery',
'queries'=>'{
posts:select post_id,source_id,actor_id,target_id,likes,stream from stream where source_id ='。$ pages [stackoverflow]。',
comments:select post_id,text ,username,fromid from comment where post_id in(select post_id from #posts)
}'
));

echo json_encode($ result);
?>

帖子返回预期结果, code>评论只返回一个评论。



此示例查询 stackoverflow Facebook页面



评论从评论返回查询是加入! (来自这篇文章)。我不知道这个评论有什么特别之处。



任何事情?

解决方案

我试图找到一个使用Graph Api的解决方案

  https://graph.facebook.com/me / fql?q =选择消息,来自stream的注释source_id = 11239244970 

正在工作,但返回注释它只返回最后一个2.它是exaclty如何Facebook本身显示流和评论与查看所有XX评论链接。



一起查询帖子和评论可以使用:

  https://graph.facebook.com/fql?q= {posts:select post_id,message ,来自stream的评论,其中source_id = 11239244970,comments:select post_id,text,username from comment where post_id in(select post_id from #posts)}& access_token = ... 

根据Facebook:


流表是限制以前30天或
50个帖子(以较大者为准),但是您可以使用特定于时间的
字段(如created_time以及FQL运算符(例如<或>)
以检索更大范围的帖子。



I want to retrieve all of the posts from a given facebook page along with the associated comments.

I wrote this code (app details obfuscated, replace with your own in order to run it).

<?php
require_once('facebook.php');
$facebook = new Facebook(array(
    'appId'  => 'MY_APP_ID',
    'secret' => 'MY_APP_SECRET',
    'cookie' => true,
));

$pages = array(
    "stackoverflow" => 11239244970
);

$result = $facebook->api(array(
    'method' => 'fql.multiquery',
    'queries' => '{
        "posts": "select post_id, source_id, actor_id, target_id, likes, message from stream where source_id = '.$pages["stackoverflow"].'",
        "comments": "select post_id, text, username, fromid from comment where post_id in (select post_id from #posts)"
    }'
));

echo json_encode($result);
?>

posts returns the expected results, but comments returns just one comment.

This example queries the stackoverflow facebook page

The comment returned from the comments query is "Joined!" (from this post). I can't figure out what's special about this comment.

Any thoughs?

解决方案

I tried to find a solution playing with Graph Api

https://graph.facebook.com/me/fql?q=select message, comments from stream where source_id = 11239244970

is working but when returning comments it returns only the last 2. It's exaclty how Facebook itself shows the stream and comments with "View all XX comments" link.

To query the posts and comments together can be used:

https://graph.facebook.com/fql?q={"posts":"select post_id,message, comments from stream where source_id = 11239244970","comments": "select post_id, text, username from comment where post_id in (select post_id from #posts)"}&access_token=...

According to Facebook:

Each query of the stream table is limited to the previous 30 days or 50 posts, whichever is greater, however you can use time-specific fields such as created_time along with FQL operators (such as < or >) to retrieve a much greater range of posts.

这篇关于从Facebook页面检索帖子和评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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