Prowling for NY Senate Bill Status Updates

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.

  1. Install the Prowl Application on your iPhone or iPod Touch and set up an account.
  2. Log into your new Prowl account and go to Settings. Generate an API key to use when invoking the above script.
  3. Download and install the ProwlPHP class library. Modify the billProwl.php script to ensure the require() statement matches your download location.

prowl_1

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.

2 comments

  1. Nathan Freitas · November 12, 2009

    Brilliant, as always! The ability to subscribe to alerts for change in status is definitely a big step forward. I’ve been working on this via Twitter…. I have also been thinking about supporting something like PubSubHubBub to support this without requiring you to poll.

    http://code.google.com/p/pubsubhubbub/

  2. Mark Headd · November 12, 2009

    Yeah, the polling is probably the big challenge with this right now. Using something like PubSubHubBub would make this a lot more efficient. Not sure if the Twitter streaming API would work, but that might be worth a look as well.

    The other big challenge is storing subscription preferences — there will need to be a way to store at least 3 pieces of information:

    * The bill number the user wants to subscribe to;
    * The medium that they want to receive notice through; and,
    * Their user name / phone number to send the alert to.

    Then each time the RSS feed is updated, a process would need to check and see who had subscribed to bills where a status change is made, and then send out a notice using the appropriate channel.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s