Search code examples
facebookunity-game-engineunityscriptfacebook-unity-sdk

unity facebook sdk get profile picture using www not working


i am trying to get facebook profile photo by using facebook sdk

when I used this code it was working fine but suddenly second day url was not downloading. url download completed is not printing, and it is showing no error.

private IEnumerator getProfilePicture()
{
    Debug.Log("Here  to get profile picture");

    WWW url = new WWW("https" + "://graph.facebook.com/" + FB.UserId + "/picture?type=square"); 

    yield return url;

    Debug.Log("url download completed");
    Texture2D textFb2 = new Texture2D(url.texture.width, url.texture.height, TextureFormat.ARGB32, false);

    Sprite sprite = Sprite.Create(url.texture, new Rect(0, 0, url.texture.width, url.texture.height), new Vector2(0.5f, 0.5f), 32);
    spriteToDisplay.GetComponent<SpriteRenderer>().sprite = sprite;
}

Solution

  • And finally after struggling for days i found the answer, and what i got is kind of strange..

    when i use the same code without changing any thing , no check nothing and run in to android device it worked fine ,

    it just had one pre-requirement that my phone should be connected to packet data and not to wi-fi...

    one thing should be noted that there is no restriction on wi-fi network and i can use facebook through wi-fi network... plus score , name and other things are working over wi-fi.....its only that if i want to profile picture to be downloaded i have to connect my phone through packet data