Posts Tagged ‘robotics’
February 25th, 2010
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.
Davis Got 4500 Followers in 6 Months

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 ;)

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? …
January 25th, 2010
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
Create Your Own Twitter Robot in PHP

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 bit.ly 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 https://twitter.com/…
# 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!
October 14th, 2009
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.
Let's Build Smart, Intelligent TwiBots!

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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| // 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("http://twitter.com/direct_messages.xml" ,
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);
$oauth->OAuthRequest('https://twitter.com/statuses/update.xml',
array('status' => $message), 'POST');
echo "Tweeting: " . $message;
sleep(rand(5,30));
}
// 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
October 9th, 2009
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.
Create a Twitterfeed Clone in PHP

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!
Read the rest of this entry »
April 14th, 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)