(Using Unity 5.2.2, Unity Facebook SDK 7.2.2)
I am trying to grab my Facebook profile picture once I am logged in, make it into a Sprite
and setting it as an Image
. The method FBLogin() is called when a Button
is clicked..
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));
}
I can't get the hang of the API syntax at all - it produces the error 400 Bad Request
. Can somebody help me out with the syntax?
Thanks