Unity Facebook API - FB.API() 语法

Unity Facebook API - FB.API() Syntax

(使用Unity 5.2.2,Unity Facebook SDK 7.2.2)

我正在尝试在登录后获取我的 Facebook 个人资料图片,将其设为 Sprite 并将其设置为 Image。单击 Button 时调用方法 FBLogin()..

public void FBLogin()
{
    perms = new List<string>() { "public_profile", "email", "user_friends" };
    FB.LogInWithReadPermissions(perms, AuthCallback);
}

private void AuthCallback(ILoginResult result)
{
    if (FB.IsLoggedIn)
    {                
        //Get Facebook Details
        getUserInfoFromFacebook();
    }
    else
    {
        Debug.Log("User cancelled login");
    }
}

private void getUserInfoFromFacebook()
{
    FB.API("/v2.5/me?fields=id,name,picture", Facebook.Unity.HttpMethod.GET, DealWithProfilePicture);
}

private void DealWithProfilePicture(IGraphResult result)
{
    if (result.Error != null)
    {
        Debug.Log("Problem with getting profile picture");
        FB.API("/v2.5/me?fields=id,name,picture",Facebook.Unity.HttpMethod.GET, DealWithProfilePicture);
        Debug.Log(result.Error);
        return;

    }

    profile_picture.sprite = Sprite.Create(result.Texture, new Rect(0,0,128,128), new Vector2(0,0));

}

我根本无法理解 API 语法 - 它会产生错误 400 Bad Request。有人可以帮我解决语法问题吗?

谢谢

你可以看到 documentation that the picture is not a field of the user, but an extra edge, which can be retrieved by requesting /me/picture:

FB.API("/me/picture",HttpMethod.GET,delegate(IGraphResult result) {
    if (string.IsNullOrEmpty(result.Error))
    {
        Debug.Log("received texture with resolution "+result.Texture.width + "x" + result.Texture.height);
        profile_picture.sprite = Sprite.Create(result.Texture, new Rect(0,0,128,128), new Vector2(0,0));
    }
    else
    {
        Debug.LogWarning("received error="+result.Error);
    }
});