How could I determine which are the best friends o

2019-04-09 20:59发布

问题:

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?

回答1:

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.



回答2:

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



回答3:

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.

  1. The applications looks through user's feed entries. 1.1. Friend who liked user's feed is given 'feed_like' score. 1.2. Friend who commented on user's feed is given 'feed_comment' score. 1.3. Friend who addressed user in his feed (whether by posting directly on his wall or tagging in the user) is given 'feed_addressed' score.

  2. Photos. 2.1. If user was tagged by a friend in a photo, profile is given 'photo_tagged_user_by_friend'. 2.2. If user tagged a friend in a photo, profile is given 'photo_tagged_friend_by_user'. 2.3. Profile will get 'photo_like' for liking a picture either uploaded by the user or a photo where user is tagged. 2.4. Profile will get 'photo_comment' for commenting a picture either uploaded by the user or a photo where user is tagged.

  3. Friends. 3.1. Profile will get 'friend_mutual' score for every mutual friend.

  4. Inbox. 4.1. Every profile gets 'inbox_in_conversation' for participating in a conversation with user. 4.2. A reparate score is given per every message for any converasation where only two people had a conversation 'inbox_chat'. photos either uploaded by user or where user is tagged.