- Home /
How to get facebook friends using playfab?
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?
Answer by zac_playfab · Sep 17, 2015 at 09:14 PM
Hey Jibran, Your API request object seems to be setup correctly. I just ran the API internally and can confirm that the service seems to be operating correctly on our test title.
There are some App and Account settings on Facebook that could potentially impact your friends list. Please verify the following:
Each account can selectively enable and disable what data it provides to an application. So for each account, confirm that under Facebook > Apps > Your App (should be registered under each of these accounts). Open the settings for your app and ensure that the account is set to provide the friends list.
Your app is configured to access the needed account information. This can be checked in the Facebook app dashboard > Status & Review. The users_friends item should be green (Live and available to all useres)
The client needs to specify the right permissions when obtaining the FB login token (via FB SDK): FB.Login("public_profile,email,user_friends", LoginCallback);
Here are the basic Facebook Docs on App permissions: https://developers.facebook.com/docs/facebook-login/permissions/v2.4#permission-email
Let me know if you are still having issues and I can take a deeper look. Any additional information you can provide will also help us determine what the root cause is.
Happy developing, -Zac