Static URL's for HTTP-In Service (No longer working)
This article is out of date!
- This script relies on a defunct external service.
Service:
LSL Redirect, is a project made to provide an easy solution for HTTP-In temporal limitation in LSL (Second Life). The system is designed to handle static URLs (permanent links) and redirect them to a specific HTTP-In URL. This HTTP-In URL can be updated or removed from Second Life if needed.
This service can be used only by LSL scripts and only for HTTP-In URLs, this is not a redirection service like 'tinyurl' or 'tr.im'.
API
With our API, you have an ID, wich is your link and a CODE. The code is used as password to identificate who is requesting changes in the ID. With the code you can update the URL or remove the ID if needed.
To keep your ID up-to-date, you have to do a frequent update, the http-in changes when the region restart, object cross-sim, object rez, object reset. Make sure you do an update each time the http-in url changes. Also, make sure you store the CODE and ID in a notecard, do not use temporal variables to store this information or you wont be able to use them.
More info about the service and its API here.
Example Code
// -------------------------------------------
// HTTP-IN v0.2 Public.
// -------------------------------------------
// Released under Creative Commons v3.5
// -------------------------------------------
// Created by Jor3l Boa (jor3lboa@sltools.biz)
// Date: 7/21/2009 - Updated:
// -------------------------------------------
// This script uses the LSL Static URL Service
// provided by www.sltools.biz. For more info
// about it, visit: http://lsl.sltools.biz
// -------------------------------------------
key createRequest;
key readRequest;
key updateRequest;
key getURL;
string myURL;
string ID;
string CODE;
//================
list ERRORS = [900,"Empty ID",
901,"Invalid URL (not http-in url)",
902,"Error creating ID",
903,"Code do not match",
904,"Empty URL-ID",
905,"Invalid ID",
910,"Invalid token"];
list mime = [HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"];
updateURL(string sAC, string sID, string sURL) {
updateRequest = llHTTPRequest("http://lsl.sltools.biz/"+sID,mime,"actionID="+sAC+"&urlID="+sURL+"&codeID="+CODE);
}
default
{
touch_start(integer n)
{
if(llDetectedKey(0) != llGetOwner()) return;
if(llGetFreeURLs() > 0) { //check for available urls
getURL = llRequestURL();
}
}
http_request(key id, string method, string body) {
if (id == getURL && method == URL_REQUEST_GRANTED) {
myURL = body;
llOwnerSay("Got HTTP-IN URL: "+myURL+" - Creating Static URL");
state createURL;
}
}
}
state createURL
{
state_entry() {
llListen(-999901,"",llGetOwner(),""); // listen for menu.
createRequest = llHTTPRequest("http://lsl.sltools.biz/create",//url
mime,"urlID="+llEscapeURL(myURL)); //urlID=http-inURL
}
http_request(key id, string method, string body) {
if (id == getURL && method == URL_REQUEST_GRANTED) {
myURL = body;
updateURL("UPDATE",ID,myURL);
}
if (method == "GET") {
llOwnerSay("REQUEST: "+body);
llHTTPResponse(id,200,"Hello World!");
}
}
touch_start(integer n) {
if(llDetectedKey(0) != llGetOwner()) return;
if(ID != "") { //avoid empty ID
llDialog(llGetOwner(),"ID: "+ID+"\nCODE: "+CODE+"\nMy URL: "+myURL,["TEST","UPDATE","DELETE"],-999901);
}
}
listen(integer chan, string name, key id, string msg) {
if(msg == "TEST") {
llOwnerSay("Sending TEST request.");
readRequest = llHTTPRequest("http://lsl.sltools.biz/"+ID,[],"");
}
else if(msg == "UPDATE") {
if(llGetFreeURLs() > 0) { //check for available urls
llOwnerSay("Getting NEW HTTP-IN URL and Updating. Wait for positive response.");
getURL = llRequestURL();
}
else {
llOwnerSay("Too many HTTP-IN URLs in use.");
}
}
else if(msg == "DELETE") {
llOwnerSay("Deleting ID, wait for positive response.");
updateURL("DELETE",ID,"");
}
}
http_response(key id, integer status, list meta, string body) {
if(id == createRequest) {
if(status >= 900) { //System returned an error.
llOwnerSay("("+(string)status+") "+llList2String(ERRORS,llListFindList(ERRORS,[status])+1));
return;
}
else if(status == 200) { //All OK
list temp = llParseString2List(body,["^"],[]); //separate ID from CODE
if(llList2String(temp,0) == "") { //avoid errors.
llOwnerSay("Empty ID returned.");
return;
}
ID = llList2String(temp,0);
CODE = llList2String(temp,1);
llOwnerSay("My ID is: '"+ID+"' and CODE: '"+CODE+"' - Touch me to test a request.");
}
}
else if(id == readRequest) {
if(status >= 900) { //System returned an error.
llOwnerSay("("+(string)status+") "+llList2String(ERRORS,llListFindList(ERRORS,[status])+1));
return;
}
else if(status == 200) {
llOwnerSay("TEST-RESPONSE: "+body);
}
}
else if(id == updateRequest) {
if(status >= 900) { //System returned an error.
llOwnerSay("("+(string)status+") "+llList2String(ERRORS,llListFindList(ERRORS,[status])+1));
return;
}
else if(status == 200) { //All OK
llOwnerSay(body);
}
}
}
}
User examples
If you have found a use to this service, share your code here.