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
Parsing the WoW Armory – Part 2.1
I forgot to post this information in Part 2 of Parsing the WoW Armory. When parsing the guild-info.xml file, some fields are represented by numerical values. Below is conversion table from XML numerical representations to actual values.
genderId:
0 - Male
1 - Female
raceId:
1 - Human
2 - Orc
3 - Dwarf
4 - Night Elf
5 - Undead
6 - Tauren
7 - Gnome
8 - Troll
10 - Blood Elf
11 - Draenei
classId:
1 - Warrior
2 - Paladin
3 - Hunter
4 - Rogue
5 - Priest
6 - Death Knight
7 - Shaman
8 - Mage
9 - Warlock
11 - Druid
For easy converting from numerical to actual values I would recommend using a PHP array(). Below is an example of the Sorted Guild list from Part 2 with the addition of the class of each character included.
< ?php function sortedList($x) { $classArray = array(1 => "Warrior", 2 => "Paladin", 3 => "Hunter", 4 => "Rogue", 5 => "Priest", 6 => "Death Knight", 7 => "Shaman", 8 => "Mage", 9 => "Warlock", 11 => "Druid"); $array = array(); foreach($x as $char) { $array[] = getName($char)." - ".getLevel($char)." - ".$classArray[(int)getClassId($char)]."<br />"; } sort($array); return $array; } ?>
Parsing the WoW Armory – Part 2
I chose to expand on Part 1 by providing a function file that provides access to all available character related information from the guild-info.xml file from the WoW Armory. The guild-info.xml file provides the following information for the entire guild: Achievement Points, Class ID, Gender ID, Level, Character Name, Race ID, Guild Rank, URL to Character Page.
Some neat things can be calculated by using the available resources. I provided three examples in the code below: Average achievement points, average level, and a sorted list of all characters in the guild (also provided in Part 1).
< ?php ini_set("user_agent", "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.2) Gecko/20121223 Ubuntu/9.25 (jaunty) Firefox/3.8"); //Average guild achievement score. function achAverage($x) { $counter = 0; $total = 0; foreach ($x as $p) { $total += getAchPoints($p); $counter++; } return ($total/$counter); } //Sorted Guild Characters Names/Levels in ABC Order. function sortedList($x) { $array = array(); foreach($x as $char) { $array[] = getName($char)." - ".getLevel($char)."<br>"; } sort($array); return $array; } //Returns the average level of the entire guild. function avgLevel($x) { $counter = 0; $total = 0; foreach ($x as $p) { $total += getLevel($p); $counter++; } return ($total/$counter); } /** * Other functions that can be used to pull information * from the XML sheet. Use these functions to expand * and create other functions. **/ function getAchPoints($x) { return $x['achPoints']; } function getClassId($x) { return $x['classId']; } function getGenderId($x) { return $x['genderId']; } function getLevel($x) { return $x['level']; } function getName($x) { return $x['name']; } function getRaceId($x) { return $x['raceId']; } function getRank($x) { return $x['rank']; } function getURL($x) { return $x['url']; } ?>
New functions can be created by using the get functions at the bottom of the file. Using the get functions and sample functions, it should be easy enough to expand on what I have.
The below code is an example of how to use the function code from above.
< ?php //Functions file. include ('guild.php'); //Set Server/Guild Here. $server = "Eitrigg"; $guild = "We+Know"; $url='http://www.wowarmory.com/guild-info.xml?r='.$server.'&gn='.$guild; $xml = simplexml_load_file($url); $xml = $xml->guildInfo->guild->members->character; //-------ABOVE THIS LINE IS REQUIRED---------- //Below are some possible ways to use the functions. /** Prints Without Array Numbers **/ for($i=0, $array = sortedList($xml);$array[$i] != null; $i++) { echo $array[$i]; } /** Alternative Implementation, Prints with Array Numbers print_r(sortedList($xml)); **/ //Displays the average number of guild achievements. echo achAverage($xml)."<br />"; //Displays the average level of the guild. echo avgLevel($xml); ?>

ScifiToday