Difference between revisions of "Profile Picture Retrieval"

From Second Life Wiki
Jump to: navigation, search
m (add lsl example tag)
(Updated to reflect changes to profile html.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Profile Picture Retrieval by Pazako Karu (Quick, Dirty, NEW WAY -  August 8, 2010)
+
Profile Picture Retrieval by Pazako Karu UPDATED 9/5/18
 
+
<lsl>
+
//Couldnt care less about saying I did this, have fun with it
+
//Pazako Karu 8/8/2010
+
  
 +
<source lang="lsl2">
 +
//Released as Public Domain
 +
//Pazako Karu 9/5/18
 
key ppReqID;
 
key ppReqID;
 
key ProfilePic;
 
key ProfilePic;
Line 25: Line 24:
 
         getProfilePic(llGetOwner());
 
         getProfilePic(llGetOwner());
 
     }
 
     }
 
 
     http_response(key req,integer stat, list meta, string body)
 
     http_response(key req,integer stat, list meta, string body)
 
     {
 
     {
 
         if (req == ppReqID)
 
         if (req == ppReqID)
 
         {
 
         {
             integer s1  = llSubStringIndex(body,"<meta name=\"imageid\" content=\"");
+
             integer s1  = llSubStringIndex(body,"<meta name=\"imageid\" content=\""); // Find the image in html
        integer s1l = llStringLength("<meta name=\"imageid\" content=\"");
+
            ProfilePic = (key)llGetSubString(body,s1+30,s1+65); // After the search text, and for 35 chars is UUID
        integer s2  = llSubStringIndex(body,"\" /> \n    <meta name=\"agentid\"") - 1;
+
            if(s1 == -1) ProfilePic = NULL_KEY; // If it wasn't found, they have no profile pic
        if(s1 == -1) ProfilePic = NULL_KEY;
+
             setProfilePic(ProfilePic); // Set the texture
        else    ProfilePic = (key)llGetSubString(body,s1+s1l,s2);
+
             setProfilePic(ProfilePic);
+
 
         }
 
         }
 
     }
 
     }
 
}
 
}
</lsl>
+
</source>
 
+
{{LSLC|Examples|Profile Picture Retrieval}}
+

Latest revision as of 19:23, 5 September 2018

Profile Picture Retrieval by Pazako Karu UPDATED 9/5/18

//Released as Public Domain
//Pazako Karu 9/5/18
key ppReqID;
key ProfilePic;
getProfilePic(key AvatarKey)
{
    ppReqID = llHTTPRequest( "http://world.secondlife.com/resident/" + (string)AvatarKey,[HTTP_METHOD,"GET"],"");
}
setProfilePic(key Texture)
{
    if (Texture != NULL_KEY)
    {
        llSetTexture(Texture,ALL_SIDES);
    }
    else llOwnerSay("Invalid texture returned!");
}
default
{
    state_entry()
    {
        getProfilePic(llGetOwner());
    }
    http_response(key req,integer stat, list meta, string body)
    {
        if (req == ppReqID)
        {
            integer s1  = llSubStringIndex(body,"<meta name=\"imageid\" content=\""); // Find the image in html
            ProfilePic = (key)llGetSubString(body,s1+30,s1+65); // After the search text, and for 35 chars is UUID
            if(s1 == -1) ProfilePic = NULL_KEY; // If it wasn't found, they have no profile pic
            setProfilePic(ProfilePic); // Set the texture
        }
    }
}