简体   繁体   中英

Unity 5.1.1f1 Facebook SDK 6.2.2 Error 400: Bad request on getting player picture on iOS

I got stuck at getting profile picture on iOS devices. It works well on Editor, Android devices, even Facebook graph . After FB.init() called successfully, i call

string url = Util.GetPictureURL(fID, 128, 128);
FB.API(url, Facebook.HttpMethod.GET, AvatarAPICallback);

Following is the url after debugged:

v2.5/626213070847481/picture?g&width=128&height=128&redirect=false

on iPhone, it returns error 400: bad request.

Any answer is appreciated! Thanks

Get the UserID and use WWW to request a user picture.

Example to download a sprite:

private IEnumerator DownloadPicture(string userID){
    WWW www= new WWW("http://graph.facebook.com/"+userID+"/picture?width=200&height=200");
    yield return www;

    if(www.error==null)
        userPicture = Sprite.Create ((www.texture as Texture2D), new Rect (new Vector2 (0, 0), new Vector2 (www.texture.width, www.texture.height)), new Vector2 (0.5f, 0.5f));
    else
        userPicture = defaultPicture;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM