Update multiple twitter accounts via SMS from one phone
Ever wanted to update multiple twitter accounts via SMS, but only have one phone?
There is a sneaky way of doing this - provided you don't mind losing ~3 characters!
1. Create a new account
Yes, create yet another account. This account should have no friends or followers, and should have the tweets protected. That's right, so no-one can see them. You should set your phone up to update this account... bear with us! We'll refer to this account as the "Bucket" account.
2. The script of cleverness
What we now do is set up a script to read the tweets from this bucket account and forward them on to the correct real account. How? Start your message with a hash tag reference, and make sure the script knows about this tag!
There is a great example of this up and running and accepting new registrations at bucket.harrybailey.com but I chose to implement my own, mostly because I'm just like that, but for a few reasons listed below.
So say I have 3 accounts I want to update - 'a', 'b' and 'c'. I can assign these to appropriate hash tags - in this case, '#a', '#b' and '#c'. Then, when the script reads the tweets from the bucket, it checks for a hash tag, and knows which account to forward the tweet to. It will also remove the hash tag.
What if there is no hash tag? I set up a default account option, so I don't have to remember to add tags for my most-used twitter account.
I've then set up three tags - #e, #r and #n - to send me an email - and if any other tags are detected, it'll email me with an error message.
It will also log all actions, to make bugfixing easier.
There's an example under #p for calling another script that could process the tweet - see Finally thought of a use for my twitter script! for my ideas.
Harry's site is excellent - but currently is restricted to listing 3 accounts (including the bucket account), so only allowing you update two different accounts; and it only checks every 5 minutes. That's an API rate limit issue, but since my script is only going to do my accounts, I've been able to set the script to run every minute with a cron job. And, of course, with my script being on my site, it allows me to do much more...

Here's my PHP code. I used abraham's twitteroauth libraries but hopefully this is a simple enough example to be ported to other libraries and languages.
<? define('CONSUMER_KEY', 'MYKEY'); define('CONSUMER_SECRET', 'MYSECRET'); include('twitteroauth.php'); $mailTo = 'default@email.addresss'; $account['a'] = 'account_1_name'; $token['a'] = 'account_1_token'; $secret['a'] = 'account_1_secret'; $account['b'] = 'account_2_name'; $token['b'] = 'account_2_token'; $secret['b'] = 'account_2_secret'; $account['bucket'] = 'bucket_account_name'; $token['bucket'] = 'bucket_account_token'; $secret['bucket'] = 'bucket_account_secret'; $defaultAccount = 'a'; // Connect to Bucket $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $token['bucket'], $secret['bucket']); $tweets = $connection->get('statuses/user_timeline', array('count' => 5)); if (is_array($tweets)) { foreach($tweets AS $tweet) { $matches = array(); $accountRef = $defaultAccount; if (preg_match('/^#([a-z])/', $tweet->text, $matches)) { // update the account reference $accountRef = $matches[1]; // strip the tag $tweet->text = substr($tweet->text, 3); } switch($accountRef) { case 'a': case 'b': case 'c': sendTweet($tweet->text, $accountRef); break; case 'e': case 'r': case 'n': mail($mailTo, 'Reminder from text message', $tweet->text); writeLog('Email reminder: '.$tweet->text); break; case 'p': include('addPetrol.php'); writeLog('Petrol Record: '.$tweet->text); break; default: mail($mailTo, 'Unknown twitter request', '['.$accountRef.']: '.$tweet->text); writeLog('Unknown request: ['.$accountRef.']: '.$tweet->text); } // remove from the bucket $connection->post('statuses/destroy', array('id' => $tweet->id)); } } function sendTweet($text, $accountRef) { global $account, $token, $secret; $sendTweet = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $token[$accountRef], $secret[$accountRef]); $sendTweet->post('statuses/update', array('status' => $text)); writeLog('Sent "'.$text.'" to "'.$account[$accountRef].'"'); } function writeLog($msg) { $f = fopen('/var/log/tweets','a'); fwrite($f, date('r').' '.$msg."\n"); fclose($f); }

Comments
This is great! But how the
This is great! But how the heck do I use it? I know a little about computers, but I don't even understand what I'm supposed to DO with this script. Any newb-friendly instructions on how to implement this? For the layman?
Set up a cron job to run the
Set up a cron job to run the script every 1/5/10 minutes (depending on what you want). Can't believe I left that out - sorry!