User:Opensource Obscure/http
< User:Opensource Obscure
Jump to navigation
Jump to search
Revision as of 21:13, 13 February 2009 by Opensource Obscure (talk | contribs) (New page: With this script, a prim requests a new LSL Server public URL, then makes a http call that updates a db with the prim's public URL. <br>This is probably horrible, I can't code, don't use t...)
With this script, a prim requests a new LSL Server public URL, then makes a http call that updates a db with the prim's public URL.
This is probably horrible, I can't code, don't use this if you don't know what you're doing.
<lsl> string a; string b; // NOT NEEDED key http_request_id; string url = "http://....php?q="; // PHP PAGE TO MANAGE DB
default {
state_entry() { llRequestURL(); } http_request(key id, string method, string body) { if (method == URL_REQUEST_GRANTED) { a = body; llOwnerSay("MY URL: " + a); http_request_id = llHTTPRequest(url+a, [], ""); } else if (method == URL_REQUEST_DENIED) { llOwnerSay("Something went wrong, no url. " + body); } else if (method == "GET") { llHTTPResponse(id,200,"Hello World!"); b = llGetHTTPHeader(id, "user-agent"); // NOT NEEDED llOwnerSay("USER AGENT: " + b); // NOT NEEDED } else { llHTTPResponse(id,405,"Unsupported Method"); } }
touch_start(integer total_number) { llOwnerSay("MY URL: " + a); http_request_id = llHTTPRequest(url+a, [], ""); }
http_response(key request_id, integer status, list metadata, string body) { if (request_id == http_request_id) { llInstantMessage(llGetOwner(), body); } }
}
</lsl>