Created
October 26, 2009 18:50
-
-
Save mheadd/218918 to your computer and use it in GitHub Desktop.
Get bill status updates from the NY Senate Open Leg API sent to your Prowl iPhone client.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Contents of file billProwl.php | |
*/ | |
// Include PHP Prowl class. | |
require('path/to/ProwlPHP.php'); | |
// The argument passed in when the script was invoked (bill number). | |
$billToLookFor = trim($argv[1]); | |
// Prowl API key. | |
$prowlKey = trim($argv[2]); | |
$prowl = new Prowl($prowlKey); | |
// Settings to use when invoking Prowl API. | |
define("APPLICATION", "BillProwl Script"); | |
define("EVENT", "Bill Status Update"); | |
define("PRIORITY", 1); | |
// NYS Leg RSS feed to parse. | |
define("OPEN_SENATE_RSS", "http://open.nysenate.gov/openleg/feed/"); | |
// Parse the recent actions RSS feed and look for a match. | |
$billFeed = simplexml_load_file(OPEN_SENATE_RSS); | |
foreach ($billFeed->channel->item as $bill) { | |
$billNumberText = substr($bill->title, 0, strrpos($bill->title, ":")); | |
$billNumberArray = explode(" ", $billNumberText); | |
$billNumber = trim($billNumberArray[0]); | |
// If a match is found, get the details and send a notice. | |
if($billNumber == $billToLookFor) { | |
// Get bill details. | |
$billUpdateDescription = substr($bill->title, (strrpos($bill->title, ":")+2), strlen($bill->title)); | |
// Send the notice to the Prowl API. | |
$prowl->push(array('application'=>APPLICATION, | |
'event'=>EVENT, | |
'description'=>$billNumber.": ".$billUpdateDescription, | |
'priority'=>PRIORITY) | |
,true); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment