Creating a Simple SMS App - HackerNews (hn)

comments edit

As I was sitting around I wondered what the top post in HackerNews was. Sure, I could have installed one of hundreds, or thousands, of apps or news readers. I could have even fired up my mobile browser or navigated via a bookmark. However, I wanted to see what it'd take to create an SMS wrapper around HN. Why? More like, why not?!

Here it Goes

First things first, I create an SMS app on SMSCMD like this blog post describes. I basically support these types of commands:

  • hn top [1-3] - ex: hn top or hn top 2
  • hn new [1-3] - ex: hn new or hn new 3

If the count is omitted, only one result is returned. Try it now, send a HackerNews command (hn top) to +13109064555.

The body parsing and HN news fetching is basically all there is. Here's my regular expression to parse the command (I actually don't receive the text "hn" as that's the SMS app name and is forwarded to that handler):

I use HackerSharp to fetch the HackerNews articles. This is what my MQTT message received handler looks like:

That's all there is to it. The only special sauce there is shortening URLs so I don't waste precious SMS space and "x.Title.Head(30)" (it gets the first 30 characters and adds ellipsis if needed). Here's what I got when I sent hn top when writing this.

MiniLock - File encryption...
http://goo.gl/7XRRKB
76 pts - poolpool | 25 comments

- Dariel Marlow

Comments