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

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.

Related

Get Facebook user friends sorted by relevance

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/

FQL: Fetch friends of a friend

How could I fetch the friends of a friend of mine with FQL or something other of the FB-APIs?
At the normal website of Facebook it's possible to see the friends of a friend of mine
if I visit his profile and add ?sk=friends to the url.
According to the FQL docs on the friends table
the friends of friends cannot be retrieved.
When you try to access a friend's friends you'll get this message:
"Can only lookup for the logged in user
or the logged in user's friends
that are users of your app."
So you can only retrieve a friend's friends who have authorized your app.
Friends of friend can access only when one friend of your friend, your friend and you (loged user) use same app and give permission to access there data.

Friends of Friends/2nd degree friend's list. Facebook Graph API

I am trying to get a list of my friend's friends using the iPhone Facebook SDK.
I've tried an approach using FQL and the Graph API but I get an error in both cases:
"Can't lookup all friends of YYYYYY. Can only lookup for the logged in user (XXXXX), or
friends of the logged in user with the appropriate permission"
I've done some research and see that this functionality wasn't available through the Facebook API up until October 2010. But then radio silence. Well, it's almost 6 months later. So was this ever implemented?
I have requested all permissions I need for my app as well.
This functionality does not exist in the Facebook Social Graph API or the FQL API.
During my quest to find out how to accomplish this I found many developers who asked the same question. Some developers have been asking for this feature for over 2 years. I think the FB team may consider it a privacy of performance concern.
I have worked on it. I was able to see friends of my friend.
It needs following requirements:
Your friend needs to be using application.
Permission from application read_stream, publish_stream, publish_checkins.
Try this fql query.
$query="SELECT uid, name, work_history FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 IN
( SELECT uid FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = $fb_id ) and is_app_user=1)
)";

facebook graph api..get friends of friends

I am using the FB graph api to get a list of my friends' friends using:
https://graph.facebook.com/<id>/friends?access_token=<token>
Now the weird thing is that this works for some of my friends and does not work for some others. Could somebody tell me why this is happening and a possible fix?
In cases where it does not work, I get the following message:
"Can't lookup all friends of YYYYYY.
Can only lookup for the logged in user (XXXXX), or
friends of the logged in user with the appropriate permission"
And I repeat, I AM ABLE to get friend lists of some of my friends using the above URL.
What permissions are being mentioned here?
Privacy permissions.
As a user, I control who can see my friends list. If I select "Friends only" then only my friends can see my list, not "friends of friends"
Log into facebook, on the upper right click on Account -> Privacy settings,
then Click on "View Settings" under "Connecting on Facebook"
"See your friends list" is what controls this.
Edit: Sorry, had to think about that for a minute.
You can see your friend's friends via the standard Facebook web UI. Your app is not you. Even though you've granted the app access to your account, your friends have not. In that case, you're not going to get back your friend's friends unless they have it set to "Everyone". Your app is not a friend of a friend.
I believe that's the reason. The other reason could be that their API is renown for being buggy. You could always open a bug report on http://bugs.developers.facebook.net/ and if my supposition is correct, someone will let you know.
I got friends of friends(limited). I had same problem. Though it is very late for answering question, it will help somebody. That's why answering this question.
We can get friends of friends those are app users.
Try by this fql query.
$fb_id= user id whose friends of friends required.
$query="SELECT uid, name, work_history FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 IN (SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = $fb_id ) and is_app_user=1) )";
$user_info=$facebook->api(array('method'=>'fql.query',
'query'=>$query));
Indeed. It's all http requests. But if I click on the link to show John's friends, facebook lists them, and if I use the graph api and a token, it doesn't. Either way it's me asking, but the api is inconsistent.

Getting friends of friends in FB graph API

I would like to get friends of friends via an API call and when I try to do it, I get the following exception,
{
"error": {
"type": "OAuthException",
"message": "(#604) Can't lookup all friends of .... Can only lookup for the logged in user (...), or friends of the logged in user with the appropriate permission"
}
}
The URL I am trying to access is,
https://graph.facebook.com/friend_id/friends?access_token=access_token
I am getting extended permissions which is as follows,
<fb:login-button perms="user_likes,friends_likes"></fb:login-button>
Could any one please let me know what's going wrong here? Or does it mean I can never get access to friends of friends?
Currently, there is no extended permission that allows you to view a user's friends of friends. The "*_likes" permissions just show you the Facebook pages that the users have Liked.
It might be possible for you to iteratively fetch and cache the friends of each of the user's friends, one by one, but without access tokens for each friend, you'll only be able to fetch public data.
I got friends of friends(limited). I had same problem. Though it is very late for answering question, it will help somebody. That's why answering this question.
We can get friends of friends those are app users.
$fb_id= user id whose friends of friends required.
$query="SELECT uid, name, work_history FROM user WHERE uid IN (SELECT
uid2 FROM friend WHERE uid1 IN (SELECT uid FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = $fb_id ) and is_app_user=1) )";
$user_info=$facebook->api(array('method'=>'fql.query',
'query'=>$query));
#Olie:
You are fetching your friends of your friend through application. So you would need permission from your friend whose friends you want. i.e. Your friend should be using that application and accepted those permission while allowing accessing information. Otherwise you wont be able to friends of your friend. I have tested this query. And it works successfully.
"message": "(#604) Can't lookup all friends of .... Can only lookup for the logged in user (...), or friends of the logged in user with the appropriate permission"
This message explains well. Read carefully.
Hope you understand solution criteria.
You cannot get friends of friends, it is not allowed due to privacy concerns.
A workaround we have done before is to save all users friends to oure own database.
That way we could cross-reference all the different users friend-list's and at least get friends of friends who have used the application we made.
Important note, such a table would quickly grow quite seizable depending on the amount of users you get.
Count on each user having about 250-300 friends on average, so if you opt for such a solution make sure to optimize your database for it, and then it should work just great.
Got same problem, had to use old REST API to get at least mutual friends, see
http://developers.facebook.com/docs/reference/rest/friends.getMutualFriends/
You can get the friends of the current user through a Graph API call to me/friends. You will need any valid access_token, no special extended permissions, just the Basic one. There is one caveat, that user must allow you to see their friend list. So in the Privacy Settings > Connecting on Facebook there is a "See your friend list" setting. If the user has chosen a custom setting and selected say "Only Me" you will get this error.
Similarly, if the current user allows others to see their friend list, but one of the friends shuts this down due to privacy concerns then you will not be able to see any data and will get that error.
I was able to verify the scenarios I have described.
Unfortunately, I can't ask your answer specifically since I don't have experience with the FB API. However, I believe that FB allows users to hide who their friends are. If they have this set, then perhaps you won't be able to access their friends at all. I'd try to modify your code to first check what the permissions of a given user are and only then accessing their friends list if you have access to it. A bit of speculation here, though.