2010-08-04 64 views
4

我想检索给定Facebook页面上的所有帖子以及相关评论。从Facebook页面检索帖子和评论

我写了这段代码(应用程序细节模糊,用你自己的替换来运行它)。

<?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返回预期的结果,但是comments回报只是一个评论。

这个例子查询stackoverflow facebook page

注释从comments查询返回“注册!” (从this post)。我无法弄清楚这个评论的特别之处。

任何虽然?

+0

您是否尝试过没有多查询的第二个查询,只有逗号分隔的post ID列表? – serg 2010-08-04 15:31:25

+0

我试过了,没有运气。 – Giacomo 2010-09-03 19:06:28

+1

您是否设法解决此问题?如果是这样,怎么样? – pAkY88 2012-02-12 14:57:59

回答

1

我试图找到一个解决方案与图形API

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

正在玩,但返回的意见,当它返回只有最后2这是exaclty如何Facebook的本身就说明了流和评论以“查看所有XX评论“链接。

要查询的信息和评论一起可用于:

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=... 

根据Facebook的:

流表中的每个查询被限制为前30天或 50帖子,然而,您可以使用特定于时间的 字段(例如created_time)与FQL运算符(如<或>) 一起检索更大范围的帖子。

相关问题