因此,最好的方法是对“流”表使用 FQL。从这里我们可以添加 WHERE 子句来完成我想要的事情。最困难的部分是 Facebook 缺乏针对特定领域提供的文档。 “类型”。
https://developers.facebook.com/docs/reference/api/user/https://developers.facebook.com/docs/reference/fql/stream/
所需权限:“read_stream”
进行初始查询“从流中选择 post_id、actor_id、target_id、消息,其中filter_key in (从stream_filter中选择filter_key WHERE uid=me() AND type='newsfeed') AND is_hidden = 0”为您提供新闻流中的大量更新。
因此,通过更改测试帐户上的一些内容,我能够找到与用户帐户上的活动更改相匹配的“类型”。
工作和教育被分组。
因此,如果我们想要具体查找一项活动,我们可以将“类型”更改为等于上面提到的 id。
$query = "SELECT post_id, actor_id, target_id, message, created_time, description, description_tags, type, place FROM stream WHERE type = '62' filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me())";
$response = $this->facebook->api('/fql?q=' . urlencode($query));
响应将如下所示:
'data' => array(
(int) 0 => array(
'post_id' => '100035395_38758242', //I've changed this post id to be random
'actor_id' => (int) 4242, //I've changed this actor_id to be random
'target_id' => null,
'message' => '',
'created_time' => (int) 1347601178,
'description' => 'Joe Smith updated his work and education on his timeline.',
'description_tags' => array(
(int) 0 => array(
(int) 0 => array(
'id' => (int) 4242, //I've changed this id to be random
'name' => 'Joe Smith',
'offset' => (int) 0,
'length' => (int) 8,
'type' => 'user'
)
)
),
'type' => (int) 305, //<--- Note the type id
'place' => null
),
);
现在我们需要意识到,教育背景和工作经历可以结合起来,其他类型也可能可以结合起来。我们可以从这里直接查询“post_id”以获取与其相关的更多信息。
$post = $this->facebook->api('/100035395_38758242');
其响应可能类似于:
array(
'id' => '100035395_38758242',
'from' => array(
'name' => 'Joe Smith',
'id' => '4242'
),
'story' => 'Joe Smith added Harvid University of America to his timeline.',
'story_tags' => array(
(int) 0 => array(
(int) 0 => array(
'id' => '4242',
'name' => 'Joe Smith',
'offset' => (int) 0,
'length' => (int) 8,
'type' => 'user'
)
)
),
'actions' => array(
(int) 0 => array(
'name' => 'Comment',
'link' => 'http://www.facebook.com/3535/posts/345345' //Changed
),
(int) 1 => array(
'name' => 'Like',
'link' => 'http://www.facebook.com/345345/posts/34534' //Changed
)
),
'type' => 'link',
'created_time' => '2012-09-14T05:39:38+0000',
'updated_time' => '2012-09-14T05:39:38+0000',
'comments' => array(
'count' => (int) 0
)
)
另一种方法是直接查询用户 ID 并提取与“类型”相关的字段。 IE。 “工作”或“教育”。
$friend = $this->facebook->api('/242?fields=work,name,education,id');
注意:如果您需要 X 周或几个月前的数据,您应该在 Facebook 查询中使用“created_time”,否则您将被限制为:每个查询 30 天或 50 个帖子。