// SL Twitterbadge script // Puts up floating text of the last few Twitter updates for a // particular user. // Ordinal Malaprop // 2007-04-17 // You can change this to use all sorts of different parameters, which // I'm sure I will get round to detailing at some point. // LICENCE // This code is licenced under a Creative Commons Attribution licence: // http://creativecommons.org/licenses/by/3.0/ // Attribution in this case would probably mean a mention in the credits // somewhere; it depends on what the application is really. // In addition, it may not be sold unmodified as is. // User-configurable variables: // Set this to be the username that you want to get tweets for string USER = "ordinal"; // Set this to be colour you want the text to appear in vector COLOUR = <0.3, 0.5, 1.0>; // Set this to be the number of characters to wrap text to (defaults to 40) integer WRAP = 40; // Other options can be found at the appropriate page: // http://ordinalmalaprop.com/twitter/badge/ // Other variables, don't change unless you know what you are doing string gTweets = "Please wait..."; get_updates() { if (USER == "") return; llHTTPRequest( "http://ordinalmalaprop.com/twitter/user-timeline.php?id=" + USER + "&wrap=" + (string)WRAP, [HTTP_METHOD, "GET"], "" ); } default { state_entry() { llSetTouchText("See more"); llSetText(gTweets, COLOUR, 1.0); if (USER == "") { llOwnerSay("You have not set a Twitter username to check."); llOwnerSay("Please edit the script in this object and retry."); } else { llOwnerSay("Checking updates for user " + USER + "..."); get_updates(); llSetTimerEvent(60.0); } } timer() { get_updates(); } on_rez(integer p) { llResetScript(); } touch_start(integer n) { if (USER != "") { // Launch the person's full Twitter page llLoadURL( llDetectedKey(0), "See all Twitter posts for user " + USER + "?", "http://twitter.com/" + USER ); } } http_response(key query, integer status, list metadata, string body) { if (status != 200) { // Couldn't contact the proxy script, don't do anything return; } if (llGetSubString(body, 0, 4) == "ERROR") { // Some sort of error from the proxy if (body == "ERROR User not found!") { // Trying to get updates for a bad username // Tell the owner and turn off the check llOwnerSay("Twitter didn't like the username " + USER); llOwnerSay("Please edit the script in this object and retry."); llSetText("No such username\n" + USER, COLOUR, 1.0); USER = ""; llSetTimerEvent(0.0); } // If we got any other sort of error, just don't update } else if (body != gTweets) { gTweets = body; llSetText(gTweets, COLOUR, 1.0); llSay(0, "New tweets received!"); } } }