How to independently ‘moblog’ / ‘blog’ via SMS

Mobile computing has always appealed to me because it’s a step away from the ‘guy-in-front-of-a-machine’ paradigm and a step towards cyborgism. Although I wouldn’t consider mobile web logging anything earthshaking, it is still a step in the right direction in my opinion. There are a few 3rd party services that facilitate ‘moblogging’ (e.g., LetMeParty.com, blogger.com) but homebrewing is more fun, more customizable, and less commercially branded. The diagram bellow illustrates how I post from my phone.

Homebrew mobile web log

(I apologize for the distortion. Please click on the image to view it in full size.)

The idea is to let Wordpress poll for emails forwarded via an AIM bot which listens for SMS messages from my cell phone. If my phone had the capability to send emails, I could have skipped the whole AIM bot thing. If I had a shell account on my web host that allowed for a persistent AIM connection, I could have modded Wordpress and skipped the email part. In the end, I wound up writing an AIM bot to get around the lack of email support on my phone as well as modding Wordpress to work with an SSL IMAP inbox.

  1. I send SMS to AIM bot.

    Have you ever received an AIM message on your cell phone? If so you’ve probably noticed that AIM actually has several short codes reserved for SMS communication between AIM clients and cell phones. (I use 265-010.) If you’re an AIM user, you can send an IM to +15556661234 which will be received as an SMS by the cell user. The cell user can then reply to that message via SMS, and AIM will forward it as an IM to the AIM user. Naturally, not every AIM SN has its own short code, so AIM servers keep track of which SNs are talking to which cell phone numbers for a few minutes. This is great, but how do you initiate an IM to an AIM user via SMS? A lesser known feature (that I found in some pdf I probably wasn’t supposed to be reading) is that you can explicitly address any AIM sn by sending a text message in the following format to one of the AIM short codes:

    AIMsnHere: message goes here

    This allows to me to communicate with my AIM bot.

  2. AIM bot sends email to Gmail account.

    The AIM bot’s job is easy. It makes sure that the incoming text message is from my cell phone number, and then copies the contents of the message in an email to a Gmail inbox. I also insert a secret string into the body of the email as a layer of security. To actually send the email from Perl, I used the Net::SMTP::SSL package. See here for a sample script.

  3. Wordpress polls Gmail account for new emails and posts them.

    To make this happen, I had to edit wp-mail.php in my Wordpress codebase. As it stands, the ‘Post via e-mail’ feature is only compatible with insecure POP3 inboxes. Gmail offers both POP3 and IMAP access but only over SSL. The wp-mail.php script was relying on some custom POP3 class, so I stripped all that out and replaced it with calls to the PHP IMAP module (imap_*). For this to work, PHP has to be compiled with both IMAP and SSL support. Fortunately, Arvixe had it covered. The important line in wp-mail.php is the invocation of the wp_insert_post() function which actually creates the post. The function is documented here. Finally, I set up up a cron job on my web host to execute wp-mail.php every 15 minutes.

It’s not the most elegant solution, but it was fun stringing all these technologies together.

P.S., Those of you who know me understand why I sometimes put ‘blogging’ in quotes. On the one hand, ‘blog’ and its derivative words are universally understood and therefore convenient (if not essential) when communicating about hypertext logs. On the other hand, the word is shifting from its origins as a portmanteau of ‘web’ and ‘log’ towards a symbol of commerce and anti-human marketing, much like the word ‘podcast’. It’s bizarre. Imagine if instead of cell phone we had ‘SuperVerizonComm2000′. Imagine if instead of television we had ‘ComcastVision123′. Well, instead of internet radio we really do have ‘podcast’. I keep it real by wrapping these words in quotes.

5 comments.

  1. aww yeah boyee i am gonna implement this TONIGHT fo sho!

  2. This is exactly the sort of stuff I was looking for.

    Thanks,

  3. [...] today I sent an SMS post which did not go through because my AIM bot was offline. (Thank you, power outages.) What surprised [...]

  4. Thanks very much for the tip about “sn: message” syntax. Officially that seems to be either undocumented or close to it.

  5. Hey can you share how you edited wp-mail.php to incorporate IMAP instead of POP3… I have been trying to do this for awhile now

Post a comment.