Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get number of friends added by facebook user in the specific time of period?

We need to get number of friends added by Facebook user in last month. We have searched in the Graph API,but didn't get any solution.

like image 680
PrateekSaluja Avatar asked Mar 01 '12 09:03

PrateekSaluja


1 Answers

I think you should use FQL notification.
But notification actually are limited to last 7 days.

Try this query:

SELECT created_time, sender_id, title_html, href, object_type
FROM notification
WHERE recipient_id=me() and object_type = 'friend' 

Update:

Another approach, a little bit tricky.
You should be able to have a look at older friendship into your 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

In this way you get all rows containing the sentences are now friends or is now friends, (note that sentences words depends from customer(?) locale settings). So you'll match all rows:

  • X and Y are now friends
  • X is now friends with X and Y...

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. https://developers.facebook.com/docs/reference/fql/stream/

Update 2:

If you want use only graph api, as far I know you have same limitation of fql (i.e. you're limited to last 7 days).

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

But this case, you cannot filter for object_type and you must find all title containings "accepted your friend request"

like image 157
freedev Avatar answered Nov 03 '22 01:11

freedev