No i’m not talking about the song by 80’s pop group Wham but rather the bug I seem to have contracted by the name of Twitter and I don’t think it will be curable anytime soon.
Firstly to make things clear it is not the constant tweeting of where I am or what i’m doing so if you thought this was a chance to find out when I have breakfast or go to the toilet then i’m afraid your going to be disappointed.
It in fact relates to the API or ‘Application Programme Interface’ side of it. I posted recently about how I managed to get ‘motion’ to automatically update my twitter account when movement is detected on a camera well i’ve started to look at other things I can ‘hook’ into it. I got my usb thermometer to tweet the temperature of my front room every hour via a script I wrote.
While I was happy with my achievements I wanted to delve into the ‘reverse engineering’ side of it ie rather than getting peripherals to post updates based on their status I wanted commands to be executed depending on what I posted on twitter.
What transpired from this was firstly a big headache and nearly a full solid day of keyboard bashing. Lunch time came and went with me not eating as I was in that dreaded ‘just 10 mins more’ mode. Alas at about half 3 I had to take a 10 minute breather before my eyes fell out and fingers seized.
At the end of it I had managed to write a script that monitors my status updates for ‘keyword’ changes and will then run another script depending on what it is. So for example if I wanted to know the temperature in my living room at any time of the day I would simply update my twitter status with something like ‘CurrentTemp’ my script would then pick this up then run my temperature script which would then output the result to twitter.
Apart from twitters own API documentation there is very little elsewhere that tells you how to do what i’ve done so the fact that the script is 100% done be me (through lots of trial and error ha) it gives a greater feeling of achievement and satisfaction. Now the bulk of the script is done it should make things a little easier to ‘hook’ into it.
In my quest for twitter automation I have hit one snag and that is that twitter only allows 150 requests to it’s API every hour. OK so this would allow a request every 30 seconds and more than enough for most users. However the backbone of my script is reading the latest update as often as possible there is no point requesting the temperature of my living room and having to wait nearly a whole minute lol. I know it sounds like i’m being a bit OTT but the other projects I have in mind will require quicker executions than 30 seconds. Â
That said this project could only be used for ‘non essential’ equipment, I wouldn’t think about using it on a burglar alarm for example as the there are too many points of failure, power cut, loss of network, twitter breaks etc etc.
Watch this space….