Search code examples
facebookfacebook-graph-apiunity-game-engineprime31

Facebook profile picture doesnt show up, it shows an icon of a question mark


Do you have any idea? I am developing an app using Unity IDE and C#. Also, I'm using the social networking prime31 for my plugin with Facebook. I was able to get all the graphs and display it in my screen app, but since last week it didn't show the profile picture and my friend's picture, it just shows a plain question mark. Do you have any idea with regard to that?

But I was able to show the username and my friend's username. My app token is working, and I am using JSON data to get the data from the Facebook URL.

void Start()
{
    getFB_ID();
}

void getFB_ID()
{
    Facebook.instance.graphRequest( "me/", HTTPVerb.GET, ( error, obj ) =>
    {

        var ht = obj as Hashtable;
        userId = ht["id"].ToString();

        Debug.Log( "USER ID: " + userId);

        string url = "http://graph.facebook.com/"+userId+"?fields=id,name,picture";
        StartCoroutine(getURL(url));

     });

}

IEnumerator getURL(string url) 
{

    WWW www = new WWW(url);
    yield return www;
    Debug.Log ("Heres the URL you are accessing:  " + url);

    ProfilePicDisplay(www.text);


public void ProfilePicDisplay(string jsonString)
{
        JsonData jsonProfilePic = JsonMapper.ToObject(jsonString);
        ConverterScript fbprofilepic;

        MyPicture = new ArrayList();

    {
        fbprofilepic = new ConverterScript();
        fbprofilepic.name = jsonProfilePic["name"].ToString();
        fbprofilepic.picture = jsonProfilePic["picture"].ToString();

        LoadProfilePic(fbprofilepic);

        MyPicture.Add(fbprofilepic.name);
    }

}

private void LoadProfilePic(ConverterScript profile)
{
    string ProfilePic = "userAvatar";
    GameObject profile_pic_holder = GameObject.Find(ProfilePic);
    profile_pic_holder.SendMessage("LoadImage", profile);
}

was able to get the data in my logs, but the problem is it didnt load the image, it says:

You are trying to load data from a www stream which had the following error when downloading. Could not resolve host: JsonData object (Domain name not found)


Solution

  • As of last week, October 3rd and detailed here: https://developers.facebook.com/blog/post/2012/10/03/platform-updates--operation-developer-love/

    The picture endpoint no longer returns the picture URL in the string. It returns a dictionary and you have to change your parsing to get to it. So the data returned will look more like this:

    {
      "id": "1234567", 
      "name": "Your Name", 
      "picture": {
        "data": {
          "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/your_picture.jpg", 
          "is_silhouette": false
        }
      }
    }