Kastang Ramblings of a Geek

13Aug/100

Push Daily Weather to your iPhone using Prowl

Below is a PHP script that will pull your daily local weather forecast from Weather Bug and push it to your iPhone using Prowl. One requirement is you have the Prowl iPhone app on your iPhone or iTouch. Prowl is $2.99 in the App Store. This script also requires PHP to be installed on your server/desktop machine. I have tested this script with a handful of random Zip Codes around the US. If I happen to come up with any special conditions, I will update the script below.

Before running this script, make sure you change the XXXXX's in $xml to your local zip code and change YOUR_API_KEY_HERE in $prowl to your Prowl API code. You will also need to change includes('API/ProwlPHP') to the location of ProwlPHP on your server.

 
/**
 * This script pulls a local XML weather forcast from
 * Weatherbug. Pushes the current days weather to a
 * device running prowl.
 *
 * This script requires ProwlPHP, and a valid Prowl API code.
 *
 * @author Kastang (josh at kastang.com)
 */
    include('API/ProwlPHP.php');
 
    //Change the XXXXX's to your local zip code.
    $xml = simplexml_load_file("http://feeds.weatherbug.com/rss.aspx?zipcode=XXXXX&feed=fcst");
 
    //Parse the description from Weatherbug.
    prowl(substr((ltrim(strip_tags($xml->channel->item[0]->description))),0,-22));
 
    //Push the weather to Prowl.
    function prowl($weather) {
        $prowl =new Prowl('YOUR_API_KEY_HERE');
 
        $prowl->push(array(
                        'application'=>'Weather',
                        'event'=>'Today',
                        'description'=>$weather,
                        'priority'=>0,
                    ),true);
    }

I have this setup daily to run at 8am using cron. Below is an example you should add to crontab if you want to do the same thing:

0 8 * * * /path/to/weather.php
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.