LSL Wiki Mirror 10-5-2006: DirtyMcLean

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings ::
Dirty McLean
- Music producer, codemonkey, and love machine (but not necessarily in that order)
- Admires those who teach for free (then pities those who get what they paid for)
- Once ate 2 Grand Slam breakfasts in a single sitting, sans the eggs (they were runny)


Things everyone should know:




Bugs / Annoyances:






Requests / Wishlist:






- REFERENCE SECTION -


Event Guide for Attachments:

attach from inventory attach from ground drop attachment to ground teleport while attached
on_rez? YES NO NO NO
attach? YES YES YES NO
changed? NO NO NO YES


llHTTPRequest Example:

//LSL HTTP POST Example
//by Dirty McLean
//June 30, 2006
//Use freely!

default {
    state_entry() {
        //replace this url with your own
        string url = "http://mysite.com/myscript.php";
        //set params to [] for GET requests
        list params = [HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"];
        //set the body to your list of variables separated by semicolons
        string body = "var1=test1&var2=test2";
        
        llOwnerSay("Requesting "+url);
        llHTTPRequest(url,params,body);
    }
    http_response(key query, integer status, list meta, string body) {
        //say the page title only
        string title;
        list split = llParseString2List(body,["<title>", "</title>"],[]);
        if (llGetListLength(split) > 1) title = llList2String(split,1);
        else title = "unknown";
        llOwnerSay("Page title: "+title);

        //say each line received
        list lines = llParseString2List(body,["\r\n", "\r", "\n"],[]);
        integer i = 0;
        integer len = llGetListLength(lines);
        for (;i<len;++i) llOwnerSay(llList2String(lines,i));
    }
}

You can test the above code with the following PHP script:
<?php
echo $_POST['var1']."\r\n";
echo $_POST['var2']."\r\n";
?>
There is no comment on this page. [Display comments/form]