Robots Are Doing Better Than Humans on Twitter

This is all about an experiment I started back in July 2009, called TwiBots. Initially it was supposed to be a simple 24/7 online tweep (Michael Davis) saying a bunch of stuff randomly. But then we (Michael and I hehe) started picking out certain topics, feeding content from certain RSS feeds, filtering all content by keywords and regular expressions.

When the new Retweet API came along, I wrote an RT module which uses the Twitter Search API to find relevant tweets and users, then retweets those messages or just somehow interacts with a user. As soon as the Twitter Lists API was announced, I started working on the Lists module, which eventually became a simple “sorting-the-tweeps” based on their keywords – web design, design, wordpress, etc. Soon enough, I found out that Lists couldn’t contain more than 500 members (although some glitch made 501 possible). Web design 2, wordpress 2, etc wouldn’t be as fancy. I also tried building a conversation list of tweeps that by any means talked to the robot, but then again, the 500 limit broke all my hopes ;)

There were other modules which I worked on really hard, such as RThx module or Random Buzz, DM Control. Some of them worked, some of them were turned off after a few days (yes, you guessed it – Random Buzz, that really made some noize ;)

So, what did I achieve? Me – nothing. Michael did though, in 6 months he went up to 4500+ followers, while following a little more than 200 people himself, has been featured in ~ 250 lists, sent ~ 55,000 tweets and retweets all based on four keywords (or hashtags) – design, web design, wordpress and jquery. Built 4 lists based on these keywords, 500 members in each. Total list followers is a little less than 150 (which is quite good actually).

For comparison take a look at my account – (@kovshenin), in a little bit more than a year I got ~ 1700 followers. It took Michael a couple of months to reach that. The chart below illustrates the followers growth during the last three months. Human (me – blue) vs Robot (Michael – red). Yeah, I added a new module in mid December ;)

Twibots Chart: Robot vs. Human

I manually logged into Michael’s account recently to check out how he’s doing, and I was kind of surprised to see that people really are talking to the guy, thanking him for retweets, asking him for further reads, wishing him a great day and handing over some coffee. Michael doesn’t usually reply to these and he’s a little bit shy sometimes, besides, he never drinks coffee ;)

A few days ago I decided to give Michael a rest, so tuned his backend to a new Twitter account with a few different settings, especially in timing. I’ll be switching to other keywords and feeds in the next few weeks. So let’s see if he’s as good as Michael, or perhaps better? ;)

I’m not sure what I’ll do with Michael’s account. TweetValue said it’s worth over $5k … anyone? ;) Or should I just throw it away.. Or run a contest for his password? …

Twitter Robot in PHP: Twibots Draft

As I promised quite some time ago, I’m putting out a draft of the Twitter Robot I wrote. Make sure you read Create Your Own Automated Twitter Robot in PHP before going on. The current functionality is as follows:

  • Tweets around the clock
  • Tweets from RSS feeds, supporting prefix and postfix text (for adding hashtags)
  • Retweet via the Twitter Search API and build conversation lists
  • Shoot random sentences at users who mention you, thank them for retweets
  • Control your robot via your own Twitter account by sending him direct messages
  • All this is Twitter OAuth powered, no password required
  • Such robots are called Twibots

Now, before downloading the code, I have to warn you that it’s completely unorganized. The code is horrible, comments are awkward, the database being used is SQLite (just for the fun of it) and it’s very very glitchy. Be prepared for Twitter suspending your account for ‘strange activity’ and use this at your own risk, don’t run here blaming me for that ;) I also suggest you’d contact Twitter to get your IP addresses and Twitter account white-listed before you start, especially if you plan to tweet very often (which I wouldn’t recommend). Use this at your own risk, and please keep my copyrights and preferably the OAuth application IDs.

Download: here (version 0.1)

Operation Instructions.. To say the truth it’s pretty tough, no web interface, not buttons, no config files. There are a bunch of files there, some of them useless. There’s the Snoopy class for reading and parsing RSS, there’s the Twitter OAuth class, and two core php files – cron.php and oauth.php. Open up cron.php, there are some comments and examples there. Make sure you get your own API key and secret. Also make sure you get a connection with the twibots.sqlite database which has a couple of empty tables. Those will be used for tokens and dump data for unrepeated tweets.

Once you’re done configuring, use the command-line php in order to make it work. It goes something like this:

# php cron.php oauth register
# Please browse to
# php cron.php oauth validate 123465
# Authentication successful, greetings @ev ;)

# php cron.php random
# tweeting a random RSS feed ...

# php cron.php reply
# sending replies...

# php cron.php dm
# reading direct messages

# php cron.php retweet
# retweeting...

You’ll have to put that in your crontab file and launch by schedule. Don’t run them too often though, as Twitter doesn’t like flooding, especially from newly created accounts. Any questions or suggestions are welcome in the comments below, but please, don’t tell me the code is horrible, I know it is, and I wouldn’t have posted it if you didn’t ask ;) Cheers!

Automated Twitter Bot in PHP: Remote Control

Hope you’ve all read the first part of this series – Create Your Own Automated Twitter Robot in PHP and got your own prototype up and running. Today we’ll be adding a remote control feature to our robot. It’ll be working through direct messages and running in crontab every 5 minutes or so. You can extend this as far as you want (adding retweet capabilities, follow/unfollow, direct messaging other people, etc) but we’ll stick to simple status updating in this post, might cover the others later on.

So, direct messaging the robot’s twitter account with the text “update status text” would make him tweet “status text” to the public timeline. Remember we had three branches of actions – feed, reply and rthx? Let’s add a fourth one and call it dm. This branch will simply scan through the account’s latest direct messages, find those sent by you and tweet them out loud. Again, as I said in the first tutorial, this is simply a prototype, just to get things up and running. You’ll have to polish this off for actual use and yeah, storing the access keys, dm_since_id, etc on disk is not such a good idea, you should probably use the database. Here’s the code:

// The id of the latest read direct message will be stored in
// a file called dm_since_id, just like mentions_since_id
// in the previous examples
$since_id = @file_get_contents("dm_since_id", true);
if ($since_id > 0) { }
else { $since_id = 1; }

// Retrieve the direct messages into $dms and parse the xml string
$dms = $oauth->OAuthRequest("" ,
	array("count" => 10, "since_id" =>  $since_id), "GET");
$dms = simplexml_load_string($dms);

// If it's valid read the latest id and store into dm_since_id
if (count($dms))
	$last_id = ($dms->direct_message[0]->id > $since_id) ?
		$dms->direct_message[0]->id : $since_id;
	file_put_contents("dm_since_id", (string)$last_id, FILE_USE_INCLUDE_PATH);

// Loop through the messages
foreach ($dms->direct_message as $dm)
	// Make sure you're the sender
	$sender = $dm->sender->screen_name;
	if ($sender == "kovshenin")
		// What should we do
		if (strtolower(substr($dm->text, 0, 7)) == "update ")
			// Construct the message, tweet and wait a few seconds
			$message = substr($dm->text, 7);
				array('status' => $message), 'POST');
			echo "Tweeting: " . $message;

		// Add more actions here

Read through the comments in the code and you should be able to get the idea. The direct messages Twitter API method is documented here. Test it out a few times through your SSH client by sending a direct message to your robot with the text “update Updating my status” or whatever, then run:

# php robot.php dm
Tweeting: Updating my status

If everything works fine you might as well add the action to your cron, say 5 minutes:

*/5 * * * * php /home/youruser/twibots/robot.php dm

And done! Your robot is now remote controlled. A few suggestions to more advanced remote controlled operations would be:

  • Retweet capabilities by regular expression
  • Adding and removing feed sources, prefixes and postfixes
  • Turning on and off other operations (feeding, replying, rthxing)
  • Adding people to “reply ignore lists” (ones that talk to your robot too much)
  • Adding people to “rthx ignore lists” (ones that retweet too much, twitterfeed for instance)

I think that’s enough for a start, oh and please don’t build dumb and annoying spammish robots. Stick to intelligent, smart twibots! ;)

Upd. Continued: Twitter Robot in PHP: Twibots Draft

Create Your Own Automated Twitter Robot in PHP

The ultimate guide to creating your own personalized twitterfeed clone! Kidding… Actualy this is just a mockup, a simple prototype, which is way too fresh for any actual use. We’ll take this forward step by step. I’m not going to give out all my sources but I’ll guide you through authentication, rss lookup, parsing, thanking for retweets, and shooting random stuff at people that mention your robot.

Here’s a brief list of features we will implement:

  • Runs in console, no HTTP access
  • Authentication via OAuth, tweeting via OAuth
  • RSS lookup, parsing, forming tweets in bound of 140 characters including a postfix (hashtag or RT)
  • Tweeting ‘thank you for retweeting’ to users that retweet the robot
  • Following people that retweet the robot
  • Acting strange on users that mention the robot

All this is going to be setup on a linux box running crond and acting every 15 minutes or so. Are you ready? Let’s do it!

Continue reading

More on Robotics: AR-600 Moscow (March 2009)

Y’all know Russian, don’t you? Kidding.. The guys in the video talk about the development of robotics in Russia, why people are afraid of robots and why they shouldn’t be (the three laws of robotics by Asimov). This “thug” (AR-600) can now make some steps back and forth then side to side (though they don’t show them on this exhibition, cause it requires a special surface). He can also recognize people’s faces and greet them individually. Oh, and almost forgot, he can read numbers from papers and add or subtract them! Smart ass! ;)

P.S. Available in HQ (click the play button, then HQ next to the full-screen button)

AR-600 in Moscow

Okay, these are kind of old from an exhibition in Moscow in like December 2008. Previously hosted by Flickr, and today I decided to have duplicates here, ’cause Flickr will not display more than 200 photos from my photostream, so here’s probably a safer place (unless my hosting provider messes up). This is an android robot, similar to Honda ASIMO. It’s called i-Van and the model name’s AR-600. It’s still being developed by Android Robotics Corp. in Russia, so I’ll get back to you with the improvements in a couple of months.

Sorry for the quality, I hadn’t had a camera back then so I caught those on my Nokia cellphone. It was fun though, our Russian president Dmitry Medvedev shook hands with the android, and then the newspapers here posted out some good photos of them both, stating that Dmitry’s standing on the right, in case somebody got confused LOL. BTW that’s me in the orange shirt. It was almost midnight and we had a bunch of technical problems, that’s why I looked so sad.

P.S. I’m on, follow me!

Robotics in Russia

Hey, just had another exhibition here in Moscow, and we’ve finally presented the new AR-600 android robot. It looks a lot like ASIMO, but it’s totally new. It doesn’t know how to walk yet, but that’s only a matter of time – the mechanics are strong enough to hold that 100 kg robot on one leg!

If anybody’s interested, be sure to check out the photos and videos right here: The blog’s in russian, but you should get the most of it ;)


A Robot Playing Ping Pong!

Woah. This is wicked! I wrote a ping pong game that had an AI player about two or three years ago in C++, the algorithm isn’t very difficult to figure out, but here’s one built-into a robot! RoboCup claims that they’ll win the international soccer championship by 2050, and I think table tennis will be much easier (because japanese are the best in robotics AND table tennis ;)