I'm currently trying to create a Facebook application with the Facebook PHP SDK.
I would like to retrieve which of the user's friends are his best friends, or the one he's most talking with.
Do you know an algorithm or a tip to get them?
I'm currently trying to create a Facebook application with the Facebook PHP SDK.
I would like to retrieve which of the user's friends are his best friends, or the one he's most talking with.
Do you know an algorithm or a tip to get them?
I quiet often need to get the list of people user is interacting most with ("best friends", in a Facebook terminology). Took a while to build the class and it is far from being perfect. However, this will save some time to people who are looking where to start.
https://github.com/anuary/ay-fb-friend-rank
The Jun 11, 2012 revision follows these rules to build friend score.
I've ran into this same issue in the app I'm working on, and open-sourced the code I've used, albeit in Ruby:
https://github.com/mikejarema/facebook-friend-rank
This is a web service which takes an active access token & user id and (assuming a read_stream permission has been granted) returns a hash of ids to counts which can be used for sorting within your application.
The friend rank algorithm looks at a user's 500 most recent interactions (activity feed) and tallies up the frequency of all friends appearing there. The result gives a reasonable ordering of friends, best to worst, and it also works on subsets of friends (eg. sorting mutual friends).
As mentioned in other answers, there's lots of room for exploring photo tags, mutual friend counts, and also looking for the type of interactions (eg. a checkin with a friend is probably a better measure of closeness than a like on their status).
Here's a sample app using this approach and Friend Rank on the backend:
http://facebook-friend-rank.herokuapp.com/demo/index.html
Simply, look for markers of friendship, give each activity a weight, total up the "friend score", and appropriate by the age of the friendship (if you're looking for a "lifetime" score). You could look at different timeframes, such as "recent best friends", etc.
I'm not phenomenally familiar with Facebook's Graph API, but if you could access the age of the friend and the number of comments/wall posts they exchange, you'd have some kind of information to go on. Think of other markers like the number of photos they're jointly tagged in, and so on.