Twittering

Updated: versions of the TwitterBox are now available for public consumption - see the main TwitterBox page, or subsequent journal entries.

I mentioned in my last entry the subject of using HTTP Basic Authentication in LSL. (For those of you not familiar, this is a simple and not very secure method of restricting access to a web page via a username and password.)

From further investigation I have come to the conclusion that "using Basic Authentication in LSL" would be a very short article, because the fact is that one does not seem to be able to do it at all. It is quite simple to send the username/password in an external request, all one has to do is send the following header as part of it:

Authorization: Basic user_pass_base64

where user_pass_base64 is the base64 encoding of "username:password". However, the LSL function llHTTPRequest does not appear to allow one to add new headers, and prefers to do them all itself; Authorization (dratted Colonial spelling) is not one that it provides a hook to.

Why was it that I was interested in this? Well, I have had some recent experience of an Aethernet Service known as Twitter, a very simple system for distributing short messages about what you are doing at the moment (or about anything, really) and also, of course, for reading other people's updates. Think of it as the most minimal sort of "blogging" system imaginable. Updates can be made and read not only on the Web, but also via or sent to one's Portable Telephone (for free I might add) or on out-of-SL Instant Message systems.

As well as simply the challenge of implementing this inside Second Life, I am interested by the potential that exists for this to be used as a system of automatic communication. Say, for example, one has a security device which instead of informing you via IM or email when it has expelled an intruder. Twitter will keep an archive of all of these notifications, and if you wish one might subscribe to it, as could any interested party; one could monitor it on the Aethernet or via Telephone or through any other mechanisms developed in the future.

(This sort of thing is often termed a "mashup", a word which makes me think of some sort of brewing procedure, but I prefer the old-fashioned term "laziness". It is far easier to have other people do the hard work of setting up a system, providing phone access and so on, than it is to do everything oneself - and being lazy in this case also benefits others who might wish to do similar things to you, as long as you make your methods known. Socially-beneficial idleness, well, things do not get much better than that, surely.)

Anyway: Twitter requires that one authenticate any requests to it via Basic Auth, and I was unable to do that in plain LSL, so I simply created an intermediary - a PHP script which could receive username, password and command from somewhere else, and send it on to Twitter, returning appropriate data formatted for use in SL. This has certain privacy implications, but at the moment anyone wishing to use this will have to trust that I am not saving their email address and password. I can guarantee that it only stores the information for a tiny fraction of a second, but if you do not trust the security of my site, well, I suppose you could host the script yourself, or just not use it.

At the present time, Twitterbox 0.1 posts and receives new friend post notifications adequately. Saying an entry on channel 282 ("too-whit-too-whoo", a rather pathetic construction but sort of memorable) sends a message, and it checks every minute for updates. I shall release the full script and PHP intermediary when I have put in some of the other functions that I am interested in, for example, a system whereby anyone coming nearby within SL wearing the Twitterbox HUD announces their user ID to your Twitterbox, giving you the option to add them as a friend. Perhaps something to automatically send SLurls to Twitter. Or similar.

For the meantime, anyone wishing to read my pointless twitterings can add ordinal to their own list. If anyone would like to help me test the above-mentioned social functions I would be obliged if they would let me know.

Anonymous's picture
26 Feb200703:09
Chance Takashi (not verified)

I had a similar problem a few months ago, except that I needed to use an authentication scheme other than Basic. The response I got when I asked about adding specific headers (which can be useful for many tricksy things) was utter bewilderment.

However, I seem to recall that it was mentioned that one may be able to do Basic HTTP authentication by using the username:password@domain URL scheme, eg. http://myusername:mypassword@www.website.com/page.cgi?var=val

Now I never tried this, as it did not fit my needs at the time, so I do not vouch for its actually working. But it may be worth a try.

Anonymous's picture
26 Feb200703:12
Ordinal Malaprop (not verified)

Hm, that's a thought. On the other hand, I find that using a PHP intermediary allows me to pass off a lot of the formatting and processing, which is an absolute pain to do in LSL, onto my server. In addition, if one has many friends, their updates may go over the limit of the data that a script is allowed to receive within LSL, even if one uses the JSON format rather than XML.

Anonymous's picture
26 Feb200706:45
Erbo Evans (not verified)

Quite an interesting notion, Madam! I shall certainly be following further developments in this matter with interest.

Your characterization of the use of external systems through their published means as "socially-beneficial laziness" is an apt one, certainly. I myself have always thought of the provision of such means for interaction with one's product (be it Engine-program, Aethernet service, or what have you) as "creating leverage." If one creates leverage and makes others aware of it, they will one day exploit this leverage, to the mutual benefit of all concerned. This "Principle of Leverage" is an important one, and designers of Enginery of all sorts should be well-advised to bear it in mind, as you have done here.

Anonymous's picture
26 Feb200709:42
Jaymin Carthage (not verified)

>using a PHP intermediary allows me to
>pass off a lot of the formatting and processing
I had to do something very similar for the Store Locator in Circut City. Their replies were much too verbose for the LSL buffer size. So I wrote an intermediary that you ping with a URL and, optionally, a prefix and suffix string to prune the reply with.

Anonymous's picture
27 Feb200705:09
qDot Bunnyhug (not verified)

I already jumped on the "Second Life" Twitter name 'cause I was thinking about doing this (using the PHP formatting idea you had here in the comments, it's by far the easiest way to format data for the world), but I have like, zero time. So, if you want access to that twitter account to make a main relay for this, just email me and we'll figure something out.

Anonymous's picture
27 Feb200707:42
Nicola Escher (not verified)

I'm enjoying tracking your tweets, Ordinal! I've been using Twitterrific (http://iconfactory.com/software/twitterrific/) for a couple months now, and Twitter has been temperamental with external apps, to say the least; so sometimes you might find problems may be on the Twitter end of things. Good luck!