Skip to main content

OpenWRT Logging via Twitter

This won’t work anymore, digest auth is not supported by twitter so see the solution by lostman to get OAuth-capable client!

Update: On Oct 29 2011 I have shut down the twitter account. Here’s how it looked like:

/galleries/dropbox/BeelineRouter%20account.thumbnail.png

/galleries/dropbox/twitter-48x48.png

Have you ever thought of your router twitting status updates? E.g. if the connection goes down and comes back you are notified right away in a light-weight fashion.

Never?

Nevermind, here’s how to do that:

  1. Create an account on twitter.

  2. Create a Basic authentication string with

    echo -n "$username:$password" | base64
    
  3. Use the following shell script, substituting $base64string with the string obtained in previous step:

    #!/bin/sh
    
    TWEET="status=$*"
    
    CONTENT_LENGTH=`echo -n $TWEET | wc -c`
    
    MESSAGE="
    POST /statuses/update.xml HTTP/1.1
    Host: twitter.com
    User-Agent: OpenWRT Twitter
    Accept: application/json, text/javascript, */*
    Accept-Language: en-us,en;q=0.5
    Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    Content-Length: $CONTENT_LENGTH
    Authorization: Basic $base64string
    
    $TWEET"
    
    echo "$MESSAGE" | telnet twitter.com 80 > /dev/null 2>/dev/null
    
  4. Save it as /usr/bin/tweet and start using it right away.

  5. Set up some cron job, make it log something and... follow your router :)

You can follow my router, just in case :)