Building a Twitter Robot Using YQL

21 Sep 2010 by admin, Comments Off

The main thing for building your own Twitter robot is to pick a word that will appear in all of your (and other people’s) tweets. Then, use the Twitter search API over and over to monitor for new tweets. As they come in, mark off the ID of that tweet so you don’t process it again. Next, have your program run whatever rules on the Tweet and send messages in response.

I recommend YQL for processing the Twitter feed because it’s ridiculously fast and can enormously cut down the amount of processing that you’ll have to do by filtering the results.
Here’s the YQL code that I’m using: USE 'http://www.datatables.org/twitter/twitter.search.xml' as twitter.search;SELECT text,from_user_id,id,from_user FROM twitter.search WHERE q='TweetDonate' AND rpp=100 AND since_id=x;

The since_id is where you put the ID that you saved earlier so that you don’t fetch the same tweets again. Depending on your application you might want to filter out a user. I’m filtering the tweetdonate user because I don’t want to reprocess my own status messages that are in response to other messages. I like returning JSON and json_decode’ing it in PHP. Instant search results using YQL.

Comments are closed.

Follow Me!

Follow Me! Follow Me! Follow Me! Follow Me!

Recent Actions