Question

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)

Was it helpful?

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
    }
  }
}

OTHER TIPS

In the latest LeanLoader, there is an automatic fix for the newly implimented Facebook endpoint abernathy mentioned, which allows you to load the image directly (with all the parsing of the json and other data handled by the engine). You can easily load profile images like this:

function Start () {
    LeanLoader.load("https://graph.facebook.com/DentedPixel/picture?type=large&redirect=false", LLOptions().setOnLoad(onImageLoaded));
}

private function onImageLoaded( tex:Texture2D ){
    Debug.Log("Your image texture ready to use! :"+tex);
}

There is also many other features that I think people will find helpful with LeanLoader (including caching of images/text/sound and a built-in JSON parser).

try this- fb sdk version-9.1.0

FB.API ("/me/picture?type=large", HttpMethod.GET, DisplayProfilePic);// API call

void DisplayProfilePic(IGraphResult result)

{
    Image profilePic;
    if (result.Texture != null)
    {
        profilePic = image1; // diplaying image
        profilePic.sprite = Sprite.Create(result.Texture, new Rect(0, 0, result.Texture.width, result.Texture.height), new Vector2());
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top