Ever since I started working on a multi-modal application for looking up the status of a bill in the New York State Legislature using the fabulous Open Leg API from the NY Senate, I’ve been thinking about ways to enable “subscriptions.”
By subscriptions, I mean allowing people to specify which bill (or bills) they are interested in and having a notice sent to them – using whatever channel they deem desirable – when the status of the bill changes. I’ve thought about how this would work for a while now, but haven’t had the time I need to sit down and actually build out the required pieces. A robust subscription framework for a service like this will require some way for people to specify their preferences (which bills they want to subscribe to, what channels they want to receive notice on, etc.) and probably some sort of process that checks for bill status updates at regular intervals and launches notices to subscribers. While not overly complex, these pieces will require more time than I have right now.
In the interim, however, I’ve been meaning to try out Prowl. Prowl is an application that lets users set up notifications (typically from their Mac or PC) that get pushed to their iPhone or iPod Touch. The Prowl client doesn’t poll a service or RSS feed, but instead receives a push when a noticeable event occurs.
The Prowl service also has an API that makes building custom apps and script that can send Prowl notices quick and easy. Since there is an RSS feed from the NY Senate that provides information on bill status updates, I thought it would be interesting to put together a quick Prowl API script that parses this RSS feed and gets the latest bill updates – it will then send a Prowl notification if a bill the user wants to track has been updated.
The sample script I worte uses the very handy ProwlPHP class library and can be invoked from the command line. Or, you can set up a cron job to check if a bill status has changed at regular intervals.
Here is the script (admittedly rudimentary, but it gets the job done).
And here is how you can use it to get Prowl notices sent to your iPhone or iPod Touch when the status of a bill you are interested in changes.
- Install the Prowl Application on your iPhone or iPod Touch and set up an account.
- Log into your new Prowl account and go to Settings. Generate an API key to use when invoking the above script.
- Download and install the ProwlPHP class library. Modify the billProwl.php script to ensure the
require()statement matches your download location.
You invoke the script by passing in the number of the bill you want to subscribe to and your API Key. See example below.
php billProwl.php S6246 your_prowl_api_key
You can also set up a cron job to check at regular intervals to see if the status of a bill has changed. The following cron entry will check every five minutes to see if bill S6246 is listed in the RSS feed for recent bill updates. If it is, it will send a Prowl notice. To keep things simple, we’ll just send any output (i.e., if there is an error when the script is invoked) to the bit bucket. If this were anything but a demo script, we would log any errors to a log file for follow up.
*/5 * * * * php billProwl.php S6246 your_prowl_api_key > /dev/null 2>&1
When I eventually have enough time to build out notifications for my NY State bill status application, I will most likely add a Prowl channel. It’s just one more way that citizens can get information from their state government on bills that they have an interest in.