Difference between revisions of "Profile Picture Retrieval"

From Second Life Wiki
Jump to navigation Jump to search
m (add lsl example tag)
m (<lsl> tag to <source>)
Line 1: Line 1:
Profile Picture Retrieval by Pazako Karu  (Quick, Dirty, NEW WAY -  August 8, 2010)
Profile Picture Retrieval by Pazako Karu  (Quick, Dirty, NEW WAY -  August 8, 2010)


<lsl>
<source lang="lsl2">
//Couldnt care less about saying I did this, have fun with it
//Couldnt care less about saying I did this, have fun with it
//Pazako Karu 8/8/2010
//Pazako Karu 8/8/2010
Line 39: Line 39:
     }
     }
}
}
</lsl>
</source>


{{LSLC|Examples|Profile Picture Retrieval}}
{{LSLC|Examples|Profile Picture Retrieval}}

Revision as of 17:37, 24 January 2015

Profile Picture Retrieval by Pazako Karu (Quick, Dirty, NEW WAY - August 8, 2010)

//Couldnt care less about saying I did this, have fun with it
//Pazako Karu 8/8/2010

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=\"");
        integer s1l = llStringLength("<meta name=\"imageid\" content=\"");
        integer s2  = llSubStringIndex(body,"\" /> \n    <meta name=\"agentid\"") - 1;
        if(s1 == -1) ProfilePic = NULL_KEY;
        else    ProfilePic = (key)llGetSubString(body,s1+s1l,s2);
            setProfilePic(ProfilePic);
        }
    }
}