Twitter Bots

So, this last weekend was BarCamp Brighton 2. I’ve already posted about that elsewhere, but what I haven’t blogged about yet is my talk.

Recently I’ve been playing around with Twitter Bots. I had a need to be able to let just the people I work with when someone had brought food into the office, so I created yahoofood. I wanted near real-time updates of when The Ten Word Review was updated, so I created the ttwr bot. I also want to allow people to review things on The Ten Word Review using their mobile phones, so I’m going to be needing to create a bot for that.

Then it dawned on me that these functionalities would be things what would possibly be of use to other people. I registered twitbot.com and started to refactor things a bit. The result is the code that’s available to download (don’t worry, it’ll be being updated as and when I write more) and the presentation that I gave on sunday morning.

Since the talk I’ve realised that I don’t really say anywhere how to call the bots. The basic pattern goes a little something like this:

$aBotVars['last_data_time'] = strtotime($aBotVars['last_data_time']);
$lastDataTime = $aBotVars['last_data_time'];

$bot = new $botClass(
    array(
        'username' => 'someUsername',
        'password' => 'somePassword',
        'last_data_time' => unixTimestampForLastDataRetrieved
    )
);
$bot->run();
$newLastDataTime = $bot->getLastDataTime();

And that’s all you need to do. Simple.

permalink | View blog reactions

other relevant pages

about wwm

workingwith.me.uk is a resource for web developers created by Neil Crosby, a web developer who lives and works in London, England. More about the site.

Neil Crosby now blogs at The Code Train and also runs NeilCrosby.com, The Ten Word Review and Everything is Rubbish.