I’ve been intrigued by node.js as a platform for highly-scalable server applications written in javascript and finally found a super simple application I wanted to try with it: an auto-tweeter that would let me schedule future tweets to my own account. I’m organizing a pub crawl for Repeal Day and I want a flight of tweets to go out during the crawl… without me or my partners having to do it manually.
I mentioned this to my buddies at Santa Barbara Hacker Space and we made it a collaborative project. I’ll miss this week’s WebTech Wednesday session, but perhaps a write up will help keep the conversation going.
The idea is pretty simple. There are three components.
- The tweet engine
- The datastore
- CRUD Interfaces to the data store
The tweet engine will query the datastore every so often and see if there are any tweets that need to be tweeted (because their tweet_by timestamp is in the past).
The datastore will hold the tweets and their tweet_by time, stored as UTC timestamps.
The CRUD interface will let us create, read, update and delete those tweets.
Future ideas:
- Use Twitter authentication for accessing the app
- Bulk uploader for multiple tweets.
- Support multiple users
- Support queues of tweets, which get tweeted at a regular schedule
- Support additional entity data with the tweets, such as geolocation
Issues:
- Managing the timestamp will take some thought. The CRUD interface should use localtime—with an option to override the timezone—but store UTC in the database. That will avoid some common problems with tweets going out on the server’s time zone when the user thought it was set for theirs.
- This first version will, unfortunately, be totally exposed to anyone who knows the URL. We’ll add twitter authentication as soon as possible.
- Timing the engine will take some finesse. We could just poll the database, but that wastes a lot of cycles. Instead, I’d like the engine to schedule itself to run at the next tweet_by time and have the CRUD either wake the process up early or kill & restart it.
That’s it for the start. More as it happens.
Hey Joe,
Thanks for the shout out! Here’s another project you may be interested in: SBitter, SBHX’s Twitter clone project… with a twist.
To quote the README: “Why throw away perfectly good Twitter clones when we could instead build a federated network out of them?” 😀 If you write a version in JS or CoffeeScript running on Node, I’ll write one in Go and another using Django!
Find out more here: https://github.com/sbhackerspace/sbhx-webtech/blob/master/sbitter/README.md
Steve,
Very cool. I’ll have to look into that. I saw the two examples, but is there any documentation for the API?
@Joe: django-sample and rails-sample are apps meant to show off very basic functionality of Django and Rails, respectively, and have nothing to do with SBitter. SBitter should probably have its own repo… I’ll do that soon.
gholms and I (and I think kitedawg) talked about the API a tiny bit, but it’s definitely still very much in the planning stages. Once we’ve got 2-3 SBitter instances, I’m thinking then we can focus more on the API… or you or your readers can drop into our IRC chat room (http://irc.sbhackerspace.com) and talk about how it should be structured immediately. 🙂
Well answered. There are a lot of crazy issues with identity and such in federated systems. Room for an interesting conversation, for sure.
Meanwhile, let me get my node.js chops in order and we’ll see what happens.
Sounds good!
Speaking of Node, Dave (the UCSB math PhD ~candidate) will be teaching us about Node/server-side JS for this coming WebTech Wednesday @ 6pm. Should be cool! Later.
–Steve
Pingback: The World’s Simplest AutoTweeter (in node.js)