/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // CONFIGURATION // /////////////////////////////////////////////////////////////////////////// // This is the url extension, ie http://tiny.cc/biose. string CUSTOM_URL = "evesim"; // Set this to the username you signed up with on // http://tiny.cc. string USER_NAME = "eve"; // Set this to the API key generatred by tiny.cc. To // generate one, visit: http://tiny.cc/api-docs and you // will see Your "API Key:" followed by a key. string API_KEY = "fbf9ba57-4d54-6fbe-89cd-761bc7a163c3"; /////////////////////////////////////////////////////////////////////////// // INTERNALS // /////////////////////////////////////////////////////////////////////////// key rlReq = NULL_KEY; key glReq = NULL_KEY; string smURL = ""; default { state_entry() { llSetTimerEvent(5); llRequestURL(); } on_rez(integer param) { llResetScript(); } timer() { if(smURL != "") { rlReq = llHTTPRequest("http://tiny.cc/?c=rest_api&format=json&version=2.0.3&m=shorten&login=" + USER_NAME + "&apiKey=" + API_KEY + "&shortUrl=" + CUSTOM_URL + "&longUrl=" + llEscapeURL(smURL), [HTTP_METHOD, "GET"], ""); llSetTimerEvent(0); return; } } http_request(key id, string method, string body) { if (method == URL_REQUEST_GRANTED) { smURL = body; return; } if(method == URL_REQUEST_DENIED) { llResetScript(); return; } if(method == "GET") { llHTTPResponse(id, 200, "UP"); return; } } http_response(key request_id, integer status, list metadata, string body) { if (glReq == request_id) { llHTTPResponse(glReq, 200, ""); return; } if(rlReq == request_id) { if(~llSubStringIndex(body, "1215")) { glReq = llHTTPRequest("http://tiny.cc/?c=rest_api&format=json&version=2.0.3&m=edit&hash=" + CUSTOM_URL + "&login=" + USER_NAME + "&apiKey=" + API_KEY + "&shortUrl=" + CUSTOM_URL + "&longUrl=" + llEscapeURL(smURL), [HTTP_METHOD, "GET"], ""); } llHTTPResponse(rlReq, 200, ""); return; } } }