How can I get user's friends (from his access token) who authorized the app as well?
$ https://graph.facebook.com/<uid>/friends?access_token=<token>
{"data":[]}
I have two friends using my app and we are all receiving an empty array.
Am I missing something ?
Thanks a lot
In order to make this work, both users (you and your friend) need to authorize the app with the user_friends permission. You can also use /me/friends btw.
Related
i have been trying to access the facebook friendlists of the facebook test users through playfab. am using this code
public void FriendLists(){
GetFriendsListRequest request = new GetFriendsListRequest ();
request.IncludeFacebookFriends = true;
PlayFabClientAPI.GetFriendsList (request, GetFriends, FriendListError);
}
void GetFriends(GetFriendsListResult result){
friends = result.Friends;
Debug.Log("Friends");
for(int i=0;i<friends.Count;i++){
Debug.Log(friends[i].Username);
}
}
I have saved the Facebook app id and secret in playfab/setting/secret keys
All my test users are friends with each other
I have also logged in from the individual accounts to play fab.
but the friendlist still returns a null.
where am i going wrong?
Make sure your test users have granted the permission user_friends to your app.
You can check the permission for each test user using their access token at https://developers.facebook.com/tools/debug/accesstoken/.
We have a thread in our ticket system, but so others have the info:
Yes, setting IncludeFacebookFriends to true will cause the API to include Facebook friends who have also played the same game (Title ID), if those friends have also linked their Facebook account to their PlayFab account, and the token permissions allow for friend info.
The most common issue we see is a mistake when entering the Facebook App ID and Secret. Can you re-check those, to ensure they match exactly?
Next, check that the players in question have all linked their Facebook accounts. If both of those check out (given that you've already confirmed the token permissions), could you send us the PlayFab sign-in credentials for a user in this state (you can email devrel#playfab.com)?
The PlayFab Friend Manager Module is specifically designed to manage friend features. There are 4 method by which we can get facebook friends using playfab.
1.Add Friend by Email
2. Add Friend by PlayFabID
3. Add Friend by DisplayName
4.Add Friend by Username
On my app, i have a feature that uses the user's facebook "user_friends" permission.
It used to work before they upgraded to API V.2.0, but now it does not:
When I created the app on FB and used test users (in development mode) my feature that includes this permission worked.
But, when i turned on the app (to be live) - it does not work.
So - it works on Test users but not on Live users.
How is that possible?
This is because /me/friends will only return those friends which also have used (via Facebook Login) the app making the request.
See
https://developers.facebook.com/docs/graph-api/reference/v2.3/user/friends/#readperms
This will only return any friends who have used (via Facebook Login) the app making the request.
If a friend of the person declines the user_friends permission, that friend will not show up in the friend list for this person.
I want to find out mutual friends between two random users using the facebook Graph API v2.2.
I read through the documentation https://developers.facebook.com/docs/graph-api/reference/v2.2/user.context/mutual_friends
It says, "A valid user access token with user_friends permission is required to view the mutual friends of other friends using the app. "
Is there a way that I can find number and possibly names of all mutual friends between currentUser and User2, if they are not friends with each other?
I referred to many other questions:
Facebook Graph API 2.2 mutual friends => No answers
How to get Mutual Friends via Facebook's Graph API => The solution works only if the two users are friends, which may not be true in my case.
I am about to implement this myself. I have a similar use case where the two users may not be friends but I'd like to see which of their friends are mutual.
Apparently, you have to include an 'app proof' parameter with the API request from your server when the two users are not mutual friends:
If you want to call this endpoint on behalf two app-users who are not friends, then you must provide the appsecret_proof parameter along with the user access token when making the request. This means you must call this endpoint from your server.
Looks like this might be a good idea to do anyway.
Managed to find a solution and it's working. If you got the call working within you and somebody else and you both are friends on Facebook, what you need to do is create the Appsecret
which represents the App secret key found on Facebook Dev under My Apps and the token. You create this key by running :
$appsecret_proof= hash_hmac('sha256', $access_token, $app_secret);
Afterwards you pass the token and the secret as parameters to the call:
Bundle params = new Bundle();
params.putString("appsecret_proof", appsecret_proof);
params.putString("access_token", access_token);
It is working for 2 users who are not friends.
Here is a working example for facebook mutual friend API:
curl -G -d "access_token=<access_token>" -d "appsecret_proof=<appsecret_proof>" 'https://graph.facebook.com/v2.5/{user-id}?fields=context.fields(mutual_friends)'
The App secret proof is sha256 of user access token with app secret as the key.
Remember both user should be using your App.
The response will have users who are also using your app and given friend list permission.
If you want to find specific info about the mutual friends try this:
curl -G -d "access_token=<access_token>" -d "appsecret_proof=<appsecret_proof>" 'https://graph.facebook.com/v2.5/{user-id}?fields=context.fields(mutual_friends.fields(id,name,picture.type(large)))'
This will return id, Name and current profile image link for all mutual friends. You don't need photos permission for this picture.
Facebook API does not allow this feature:
https://developers.facebook.com/bugs/346462608889036/
It's an old question but now I've dealt with it so I'll write...
to get all mutual friends if you not his friend it's passible only from
a server(in my case it's Node) as mention here:
https://developers.facebook.com/docs/graph-api/reference/user-context/all_mutual_friends/
get the token of user-2 and YOUR auth-id, also generate appsecretProof
and clientSecret from your Facebook admin panel of your app.
https://graph.facebook.com/v2.10/${auth_userId}?
fields=context.fields%28all_mutual_friends.limit%28100%29%29
&appsecret_proof=${appsecretProof}&access_token=${accessToken}
remember to ask permmision from users when they login and also send app review to Facebook to approve this feature.
with 'user_friends' permissions you can get from client only mutual friends that use in your app but not all mutual friends.
Technically I have two questions:
1st - Is there any way to get Facebook access, through an account, without having to create a Facebook App ?? Like having an account access token instead of an App token.
2nd - Through Facebook Graph API can I get my friends list ? I use the permission "user_friends" and I request"me/friendlist" and I only get 3 friends out of more than 400 on my friends list.
Thanks in advance.
1) No, without any App you canĀ“t get Access to anything. Even the most simple Access Token needs an App: https://developers.facebook.com/docs/facebook-login/access-tokens
2) Since April 2014, you can only get the friends who authorized the App too, for privacy reasons: https://developers.facebook.com/docs/apps/changelog
After I add a permission, the user has to remove the app and add it again, in order to grant new permission. The weird thing is that when I request a permission that the user hasn't approved, I don't get an error, but rather only an empty result set.
How do I check if the user approved a permission?
It is quite simple as you can just use the openn graph API to get that information
https://graph.facebook.com/me/permissions?access_token=....