如何获取facebook用户在特定时间段内添加的朋友数量?

Pra*_*uja 10 php facebook facebook-graph-api

我们需要在上个月获得Facebook用户添加的朋友数量.我们在Graph API中搜索过,但没有得到任何解决方案.

fre*_*dev 3

我认为你应该使用 FQL 通知。
但通知实际上仅限于最近 7 天。

尝试这个查询:

SELECT created_time, sender_id, title_html, href, object_type
FROM notification
WHERE recipient_id=me() and object_type = 'friend' 
Run Code Online (Sandbox Code Playgroud)

更新:

另一种方法,有点棘手。
您应该能够将旧友谊纳入您的stream

SELECT created_time, description FROM stream WHERE source_id = me()
and (strpos(lower(description),'are now friends') > 0 
    or strpos(lower(description),'is now friends') > 0) 
limit 50
Run Code Online (Sandbox Code Playgroud)

通过这种方式,您可以获得包含句子are now friendsis now friends, (请注意,句子单词取决于客户(?)区域设置)的所有行。因此您将匹配所有行:

  • X 和 Y 现在是朋友
  • X 现在与 X 和 Y 成为朋友...

流表的每个查询仅限于之前 30 天或 50 个帖子(以较大者为准),但是您可以使用特定于时间的字段(例如created_time)以及 FQL 运算符(例如 < 或 >)来检索更大范围的帖子。 https://developers.facebook.com/docs/reference/fql/stream/

更新2:

如果您只想使用图形 API,据我所知,您对 fql 有相同的限制(即您仅限于最近 7 天)。

https://graph.facebook.com/me/notifications?include_read=1

但在这种情况下,您无法过滤,object_type并且必须找到所有title包含的内容"accepted your friend request"