Friday, May 22, 2009

Hacking @guamtweetbot: writing a Twitter Search service

While sitting at home last night I had an idea about creating a localized service that archives all posts on Twitter having to do with Guam.  Like most other markets, Twitter's really taken off on Guam, and the number of posts about our little island, from locals and other people alike, is surging tremendously.  So the need existed to perpetuate the thoughts of those taking an interest in my hometown, and give the micromessages a little more press and some extra time in the limelight.

I set out to achieve four main goals, building-out a little autonomous service that would:
  1. Troll for new tweets having to do with Guam
  2. Harvest and retweet all found posts 
  3. Set this to run at a scheduled interval so to mirror the posts as they're appearing in the statusphere in near-realtime
  4. Follow the user that posted a new entry
So last night, inspired after a pretty healthy hot fudge sundae, I wrote a bot in PHP that makes calls against the Twitter Search API, extracting tweets containing the string "guam" and re-posting them to the @guamtweetbot timeline.  A variation of the RESTful URL called is here.

I setup the process to run as a CRON job on my Ubuntu Linux server, using wget to execute the script (since PHP's compiled for Apache, not as a CGI module):
*/20 * * * * wget -O /dev/null <path to PHP script>

This is actually a prototype for a much larger platform I'm building for KUAM, which we're going to use with our news broadcasts.  But it certainly has generated some nice feedback from the community.

Plan your code, code your plan.  Creating value for others - not a bad way to spend a Thursday evening, huh?

Comments:

Post a Comment



Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]