2

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)

Kay
  • 12,918
  • 4
  • 55
  • 77
jovs
  • 483
  • 1
  • 5
  • 9

3 Answers3

0

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
    }
  }
}
C Abernathy
  • 5,533
  • 1
  • 22
  • 27
  • Hi abernathy!thanks for the reply, you mean to say that facebook already change its JSON data?what do i need to change in my code?how can i get the right dictionary to get the picture?heres my code: fbprofilepic.picture = jsonProfilePic["picture"].ToString(); ----> do i need to add or edti something like this: fbprofilepic.picture = jsonProfilePic["picture"]["data"]["url"].ToString(); ----> it tried this one but it didnt work. – jovs Oct 10 '12 at 07:32
  • Yes you should try walking down the JSON object through data->url – C Abernathy Oct 13 '12 at 02:12
  • hi abernathy thanks its working now, amazing, so much thank you – jovs Oct 18 '12 at 06:20
0

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).

marfastic
  • 405
  • 3
  • 7
0

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());
    }
}
Kaweri
  • 1
  • 1
  • The question was solved 8 years ago, and it's not clear what value your answer brings to the topic. – hugo May 06 '21 at 11:12