As promised in my earlier post here is the code that I’m using to auto-update the MattsOffice Twitter account. With this code and a Cron job I can update the light and temperature conditions of my office automatically at whatever time interval I choose.
ioBridge.com does offer “Actions” but none of the current actions allow the trigger to be time based. Once they introduce time as a trigger this code will no longer be needed.
<?php
include_once('class.twitter.php');//http://code.google.com/p/php-twitter/
$ioBridgeJSONFeedURL = 'http://www.iobridge.com/api/feed/key=XXXXXXXXXXXXXXXXXX';
$t = new twitter;
$t->username = 'twitter_username';
$t->password = 'twitter_pwd';
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$ioBridgeJSONFeedURL);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$ioBridgeResultsObject = curl_exec($curl_handle);
$ioBridgeResultsObject = json_decode($ioBridgeResultsObject);
curl_close($curl_handle);
if (empty($ioBridgeResultsObject)){
print "Sorry, something went wrong.";
}
else{
$data = $t->update('Temperature = '. $ioBridgeResultsObject->{'module'}->{'channels'}[0]->{'AnalogInput'} . '°F / Ambient Light = ' . $ioBridgeResultsObject->{'module'}->{'channels'}[2]->{'AnalogInput'});
print '<pre>Twitter says: '; print_r($data); print '</pre>';
}
?>
In a few days I will post the code that parses my Twitter account for @MattsOffice mentions and responds to them accordingly.
Update: 07/17/09
Second post is up with more code
[...] Update: 07/15/2009 The first part of the code can be found here. [...]
Make posted a link to the original blog post:
http://blog.makezine.com/archive/2009/07/home_automation_control_via_twitter.html
[...] promised in my earlier post and the follow up post, here is some sample code I’m using to respond to @MattsOffice mentions. With a version of [...]
Brilliant! You’ve inspired me to get one of these boards…
I have never wanted something so badly! Thanks for the inspiration! That was amazing.