Get Facebook user friends sorted by relevance - facebook

Is there a way getting user friends list from Facebook as sorted on Facebook site?
For example when I tag someone in a picture, the friends offered by Facebook are sorted by relevance. Also the friends on the chat are sorted by relevance.
Is there a field which I can order by to achieve that or do I need to get parameters on each user and calculate some kind of friends ranking?

Theoretically you could use the mutual_friends_count field of the user table (https://developers.facebook.com/docs/reference/fql/user/) to do some kind of own sorting. You could query this via FQL:
SELECT uid,first_name, last_name,mutual_friend_count FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY mutual_friend_count DESC
But currently this is not working well: https://developers.facebook.com/bugs/242368225968716/

Related

Facebook query language. Get all user live in california

I am working in facebook Application MVC 4 c# SDK 6
is there any way to get the list of all Facebook User. Either friend or not, who lives in California using Facebook Query Language
List of your friends who live in California and have it list in their current location.
SELECT name, current_location
FROM User
WHERE uid IN (SELECT uid2 FROM Friend WHERE uid1 = me())
AND current_location.state = "California"
Test out the query here.
I don't think it's possible to pull this information on all Facebook users since the location column is not indexed. This answer does a good job explaining why searching by location along is not possible.
Helpful links:
how to write an fql query to list friends in a particular location
From FQL we want to get users current location in php
The one word answer is No. But you can get access to users that have made their location public.
see similar question Facebook API: can I get detailed info about user's location?

Facebook Graph API mutual_friend_count?

So it seems FQL had a field on each user called mutual_friend_count. Is there any way to get this through the graph API?
I can get mutual friends, but I am trying to sort and cull the list when a user has below a certain number of mutual friends. Using 'mutualfriends' with the friends call takes forever and returns way too much data, I only need the count of each user, not a list of every friends mutual friend.
Am I going to have to resort to using FQL to grab this or am I missing something?
EDIT:
So it seems my best bet seems to be FQL - this gives me all my current users friends that have 200 friends in common, ordered by mutual friend count. My question is just whether this can be done directly via the Graph API.
SELECT uid, name, mutual_friend_count FROM user
WHERE uid IN (SELECT uid1 FROM friend WHERE uid2 = me())
AND mutual_friend_count > 200
ORDER BY mutual_friend_count DESC LIMIT 10

FQL query isn't retrieving all the friends from the same University

I am building an app which has a feature which requires all the user's friends who go to the same university to be called.
Here is the FQL query I am using:
SELECT name, uid, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) AND ('110692668958084' IN education OR '103797159658620' IN education OR '330980680328922' IN education)
The reason for the many different school IDs is because there seems to be several different pages being used for the same university.
The problem with the query is that it only returns 8 or 9 friends (even less without all the other school IDs). Using the API explorer I have checked friends that do go to the same university and have not been returned by the query ( about 20+ ). I can confirm that all these friends have the same school IDs in their education attributes as the query above.
My question is: how come the query won't return all of them? is it something to do with user's privacy settings or is there something wrong with my query?
Thanks!

How to get the count of FB friends my friends have?

Now my app is seeking the following permissions from user.
user_about_me,user_birthday,email, friends_about_me,friends_relationships
I'm getting the friends of the current logged in user and their relationship status. Is there any way to get the total count of FB friends for each one of them (i.e. No of FB friends my friends have) . I don't need the friends list but its enough to get the total no of FB friends a FB user have.
Is that possible? I know that if the user haven't authorized the app we couldn't find any information. But i guess the no of friends a FB user has may be a public data!!(unless he has privacy setting over them also)..
Is that possible using any FQL queries?
I have found a solution myself. Its possible to use the FQL to get the friends count.
There is a friend_count field against the user table.
SELECT uid, name, friend_count
FROM user
WHERE
uid IN
(SELECT uid2 FROM friend WHERE uid1=me())
The above query will retrieve all my friends with their names and their friend_count.

How can I determine which friends of the currently logged in user are also using my app?

The Graph API makes it easy for me to determine who the friends of the current user are. I have two questions:
Is it possible, using the Graph API, to determine the list of users for the currently authenticated application?
Is it possible to determine the friends of the current user who are also users of my application (the intersection of my app's users and the current user's friends)? Is this possible using FQL?
No, This is not possible. Refer to this answer.
There's a rest method called friends.getAppUsers for this. Or you could use FQL:
SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) AND is_app_user=1