Having Trouble with Javascript GET and URL

Through my Unity app and the HTML page it is embedded into, I am using the Facebook SDK to grab a user’s details such as their user ID and name. Grabbing both and putting them into labels works fine. I have a template url that I can play an ID into to get their profile picture. However, when I try to use this url to get the image, it doesn’t work when requesting the user’s ID.

Here is the Unityscript code I am using:

if (windowID == 1){
		    Application.ExternalCall("GetCurrentUser");
	grabbedID = fbManage.fbUserID;
        	if(!gotPic){
      			GrabPic();
        	}
			GUI.Label(new Rect(200,100,500,500),getProfilePic.texture);
			GUI.Label(new Rect(200,600,500,500),aString);
	
	}

}


function GrabPic () {
	gotPic = true;
	aString = "ID is: " + grabbedID;
	var url = "http://graph.facebook.com/" + grabbedID + "/picture?type=large";
	getProfilePic = new WWW(url);
}

Now what happens here is that the aString label displays just fine (when the profilepic is commented out), however when the var url and getProfilePic is not commented out, the game never loads the window with ID 1 and just crashes. What is unusual is that when grabbedID is defined manually, everything works as it should and the image is pulled as well as the aString label being displayed.

I am using a WebPlayer for this, and I have no doubt forgotten something so feel free to ask if more information is needed.

You aren’t yielding the WWW getProfilePic and so not giving it any time to process - I’m guessing the hard coded value is just cached already or something. Presuming this is in a MonoBehaviour you should just be able to:

if (windowID == 1){
           Application.ExternalCall("GetCurrentUser");
    grabbedID = fbManage.fbUserID;
            if(!gotPic){
             GrabPic();
            }
          if(retrievedPic)
          {
             GUI.Label(new Rect(200,100,500,500),getProfilePic.texture);
             GUI.Label(new Rect(200,600,500,500),aString);
          }
 
    }
 
}

var retrievedPic = false;
 
function GrabPic () {
    gotPic = true;
    aString = "ID is: " + grabbedID;
    var url = "http://graph.facebook.com/" + grabbedID + "/picture?type=large";
    getProfilePic = new WWW(url);
    yield getProfilePic;
    retrievedPic = true;
}