抓住Facebook的生活事件 [英] Grabbing Facebook life events

查看:136
本文介绍了抓住Facebook的生活事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种方法来从图形API中吸引朋友的最近的生活事件,但是我遇到了一个阻拦者的位置。

Ive been looking for a way to pull recent life events for friends from the graph API but I've ran into a blocker for locations.

我知道你可以查询朋友的位置。但是,是否有可能找到以前的位置记录(或者只是一般的历史,如果有人在工作中获得晋升,以便改变角色)。

I know you can query friends for their location. But is it possible to find previous location history (or just history in general, if someone was given a promotion at work so they change their role?).

的代码,我从我的手机发布。

Excuse the lack of code as I'm posting from my mobile.

我的位置是:
- > api('/ me / friends?fields = name ,位置);

What I have for locations is: ->api('/me/friends?fields=name,location);

哪个适用于当前位置。

任何提示都会很棒。谢谢。

Any tips would be great. Thanks.

推荐答案

所以最好的方法是使用FQL对流表。从这里我们可以添加WHERE子句来完成我之后的工作。最困难的部分是缺乏Facebook在特定领域提供的文档。 Type。

So it turns out the best way to do this is to use FQL against the "stream" table. From here we can add WHERE clauses to do exactly what I'm after. The hardest part is the lack of documentation provided by Facebook on a specific field. "Type".

https ://developers.facebook.com/docs/reference/api/user/
https://developers.facebook.com/docs/reference/fql/stream/
需要的权限: read_stream

https://developers.facebook.com/docs/reference/api/user/ https://developers.facebook.com/docs/reference/fql/stream/ Permissions required: "read_stream"

执行初始查询SELECT post_id,actor_id,target_id,message FROM stream WHERE filter_key in(SELECT filter_key FROM stream_filter WHERE uid = me() AND type ='newsfeed')AND is_hidden = 0为您提供了新闻流中的更新列表。

Doing the initial query "SELECT post_id, actor_id, target_id, message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0" gives you a wide list of updates within your news stream.

所以通过更改几个我的测试帐户能够找到与用户帐户中的活动更改相匹配的类型。

So by changing a few things on my test account I was able to find the "type"'s that matched the activity changes on a users account.


  • 工作更新 - 305

  • 教育更新 - 305

工作与教育已分组。 >

Work and Education are grouped.


  • 关系状态 - 62

  • 更改的位置 - 282

所以说,如果我们想要具体,找一个活动,我们可以将类型改为等于上面提到的id。

So say if we wanted to be specific and look for one activity we can change the "type" to be equal to the id's mentioned above.

$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以获取更多相关信息。

Now we need to be aware that Education and Work history can be combined, and potentially other types can be as well. We can from here query the "post_id" directly to get more information related to it.

$post = $this->facebook->api('/100035395_38758242');

这样做的回复可能是这样的:

The response of this could be something like:

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,并拉取与类型相关的字段。即工作或教育。

The alternative could be to also query the user id directly and pull fields relevant to the "type". I.e. 'work' or 'education'.

$friend = $this->facebook->api('/242?fields=work,name,education,id');

注意:如果您需要X周或几个月前的数据,您应该使用created_time查询到Facebook,否则限制为:每个查询30天或50个帖子。

NOTE: If you require data from X Weeks or Months ago you should use the "created_time" within your queries to Facebook, otherwise you're limited to: 30 days or 50 posts per query.

这篇关于抓住Facebook的生活事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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