Jump to content

Key2Names plus profile picture


Clarke Kondor
 Share

You are about to reply to a thread that has been inactive for 4685 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

This code will allow you to get the User Name, Display Name and Profile picture UUID all with a single call.  The avatar does not have to be in the same sim as the object and it is super fast.

- Clarke

 

//Clarke Kondor, June 2011;
// Returns the User Name and Profile Picture UUID plus the current Display Name (if one exists) with a single call
// This demo version will say the names to you and put the picture on all sides of the prim

/////////////////////////WARNING//////////////////////////////
// This function uses the SL World API as of June 29, 2011
// LL does not support this API
// If LL changes the format of this API your content may break
//////////////////////////////////////////////////////////////


string TargetKey = "96ce2eec-03c4-46f6-9068-a92444650139"; // put the key of the target avatar here


string URL = "http://world.secondlife.com/resident/";
key kReq;
string UserName;
string DisplayName;
string ProfilePicUUID;

default
{

    touch_start(integer total_number)
    {
        kReq = llHTTPRequest(URL + TargetKey,[],"");
    }

    http_response(key request_id, integer status, list metadata, string body)
    {
        if( request_id == kReq)
        {

            integer StartIndex = llSubStringIndex(body,"<title>");
            integer EndIndex = llSubStringIndex(body,"</title>");

            if(status !=200)
            {
                UserName = "NULL";
                DisplayName = "NULL";
                ProfilePicUUID = "NULL";
            }

            else
            {
                if( StartIndex == -1)
                {
                    UserName = "NULL";
                    DisplayName = "NULL";
                }
                else
                {
                    string tempString = llGetSubString(body,StartIndex+7,EndIndex-1);
                    integer tempIndex = llSubStringIndex(tempString,"(");
                    if( tempIndex >=0) // contains both a UserName and DisplayName
                    {
                        DisplayName = llGetSubString(tempString,0,tempIndex-1);
                        UserName = llGetSubString(tempString,tempIndex+1,-2);
                    }

                    else // contains User Name only
                    {
                        DisplayName = "NULL";
                        UserName = tempString;
                    }
                    tempIndex = llSubStringIndex(body,"imageid")+18;
                    if( tempIndex >17)ProfilePicUUID = llGetSubString(body,tempIndex,tempIndex+35);
                    else ProfilePicUUID = "NULL";
                }
            }

            llOwnerSay("Display Name is " + DisplayName + "\nUser Name is " + UserName + "\nProfile Picture UUID is " + ProfilePicUUID);
            llSetTexture(ProfilePicUUID, ALL_SIDES);
        }


    }
}

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4685 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...