User:Opensource Obscure/LSL/Bitly
Jump to navigation
Jump to search
User page - JIRA - Interests - Groups - LSL - Places - Stores - Translations - other pages
This simple script uses llHTTPRequest() to call bit.ly APIs and shorten a link. <lsl>
string LONGURL = "http://example.org";
string BITLY_USERNAME = "CHANGE_ME"; // SET THIS WITH YOUR DETAILS string BITLY_APIKEY = "CHANGE_ME"; // SET THIS WITH YOUR DETAILS // See bit.ly API docs // http://code.google.com/p/bitly-api/wiki/ApiDocumentation
string BASEURL = "http://api.bitly.com/v3/shorten?format=txt&domain=j.mp&"; // Alternatively: JSON and XML format, bit.ly instead of j.mp domain
default {
state_entry() { llSay(0, "Hello, Avatar!"); }
touch_start(integer total_number) { llHTTPRequest(BASEURL + "login=" + BITLY_USERNAME + "&apiKey=" + BITLY_APIKEY + "&longUrl=" + llEscapeURL(LONGURL),[],""); } http_response(key request, integer status, list metadata, string msg) { if(status!=200) { llOwnerSay("Error"); llOwnerSay(msg); return; } llOwnerSay(msg); }
} </lsl>