我使用facebook sdk统一获取用户的朋友数据。但作为回应,我无法获得有关用户朋友的任何信息。
这是我正在使用的代码(使用C#)
void Start ()
{
FB.Init (onInitC, onHideU);
}
void onInitC()
{
FB.Login ("public_profile,email,user_friends",loginCallB);
}
void onHideU(bool isGameShown)
{
Debug.Log("Is game showing? " + isGameShown);
}
void loginCallB(FBResult result)
{
Debug.Log ("loginCallB FBResult.Text=="+result.Text);
FB.API ("/me/permissions", Facebook.HttpMethod.GET, APICallB_permissions);
}
void APICallB_permissions(FBResult result)
{
Debug.Log ("APICallB_permissions FBResult.Text=="+result.Text);
FB.API ("/me/friends?fields=first_name,id", Facebook.HttpMethod.GET, APICallB_friends);
}
void APICallB_friends(FBResult result)
{
Debug.Log ("APICallB_friends FBResult.Text=="+result.Text);
登录consol如下: -
loginCallB FBResult.Text=={"is_logged_in":true,"user_id":"XXXX","access_token":"XXXX","access_token_expires_at":"01/01/0001 00:00:00"}
UnityEngine.Debug:Log(Object)
LevelDesign:loginCallB(FBResult) (at Assets/Scripts_Custom/LevelDesign.cs:28)
Facebook.AbstractFacebook:OnAuthResponse(FBResult)
Facebook.EditorFacebook:MockLoginCallback(FBResult) (at Assets/Facebook/Scripts/EditorFacebook.cs:222)
Facebook.<Start>c__Iterator0:MoveNext()
APICallB_permissions FBResult.Text=={"data":[{"permission":"installed","status":"granted"},{"permission":"public_profile","status":"granted"},{"permission":"user_friends","status":"granted"}]}
UnityEngine.Debug:Log(Object)
LevelDesign:APICallB_permissions(FBResult) (at Assets/Scripts_Custom/LevelDesign.cs:35)
Facebook.<Start>c__Iterator0:MoveNext()
APICallB_friends FBResult.Text=={"data":[]}
UnityEngine.Debug:Log(Object)
LevelDesign:APICallB_friends(FBResult) (at Assets/Scripts_Custom/LevelDesign.cs:42)
Facebook.<Start>c__Iterator0:MoveNext()
答案 0 :(得分:1)
如果您的应用程序是在2014年4月30日之后创建的,则您将无法再访问用户的好友列表。 /me/friends
API端点仅向您显示已安装该应用程序的朋友。
如果您想邀请朋友使用您的应用,首先必须将其归类为游戏,您需要使用新的invitable_friends
API。
致电/me/invitable_friends
,查看您可以邀请其使用您的应用的朋友列表。