Weather-Watch.com
September 02, 2010, 05:26:41 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Members: 8,509  Posts: 362,030  Topics: 40,113
Please welcome lawrencerebeiro, our newest member.

Latest versions: WD - 10.37P  WDL - 6.05  MML - 1.03
 News:
Check out the new FAQs (Frequently Asked Questions) board for a growing list of hints, tips and diagnostic suggestions.
  Advanced Search
   Home   Bug Tracker Photo Gallery Wiki Chat Calendar Search Login Register Help  
Pages: [1] 2 3 ... 13
  Print  |  « previous  |  next »  |  Go Down  
Author Topic: NOAA Top Weather Advisory Alerter PHP Script  (Read 15117 times)
0 Members and 1 Guest are viewing this topic.
MCHALLIS
Rain Maker
***
Offline Offline

Location: Long Beach, WA USA
Station Type: Davis VP2+
Posts: 1,997
Local Time: Thursday 11:26



WWW
« on: July 08, 2009, 10:09:38 PM »

NOAA Top Weather Advisory Alerter PHP Script by Mike Challis

Version: 1.16 - 28-Oct-2009 - NWS recently added County codes in addition to Zone codes.
Changed code to allow Zone or County codes.

Version: 1.15 - 09-Sep-2009 - Added setting
// normally when the Advisory is canceled or expires, and the cache is updated,
// it sends out email/text alert stating "There are no active watches, warnings or advisories".
// disable this?
$disable_expired_message = false; // change to true to disable alert ended alert

Version: 1.14 - 02-Sep-2009 - Fixed zone name twice in alert message, and more improved top alert selection.

Version: 1.13 - 01-Sep-2009 - Fixed error when Air Quality Alert, improved top alert selection.
If it cannot figure out which alert is the top most alert, it will select the 1st one.

Version: 1.12 - 31-Aug-2009 - If you have one of the rss-asvisory.php or rss-top-warning.php script that is pre version 2.00  
the cache file could conflict with the other script.
If this condition is detected, the script will output: "Advisory Information Unavailable, cache file conflict, view source for details."
If you view the source you will see more details about the cause and how you can fix it (upgrade your other scripts to 2.00 or higher, or rename the $cacheName setting to something other than rss-advisory.txt).

Version: 2.00 - 13-Jun-2010 - added OAuth/Twitter authentication (TweetWX642) because user/password authentication is being disallowed after June 30th, 2010 (Thanks to Joe Chung and Ken True for providing the auth code)

Partially based on a variation of the following scripts:
RSS Top Warning PHP Script by Ken True http://saratoga-weather.org/scripts.php
PHP NOAA Advisory Text by Tom Chaplin http://www.carterlake.org/weatherphp.php
warnscroll.php by Jim McMurry - http://jcweather.us
Twitter Code from http://morethanseven.net/2007/01/20/posting-to-twitter-using-php/  

What does it do?
Ever want to receive severe weather alerts by cell phone, blackberry, Twitter, or email?  now you can.
This PHP script checks the NOAA RSS Weather Alert feeds on a timed schedule, then messages you if an alert status changes in the zone you have set.
The alert message is short enough to send to a cell phone, blackberry, or email.
Twitter is also optionally supported. Supports sending messages by email and Twitter.

Includes most of the features of the NOAA RSS Top Warning 2009 PHP Script
http://www.weather-watch.com/smf/index.php/topic,40256.0.html

What do I need?
PHP 5 is required
.. Web server hosting account with PHP support and ability to send emails from PHP
.. Ability to schedule a cron job or a scheduler program on your PC that can request a URL every 15 minutes.
.. your PHP server must allow PHP scripts permission to write files. safe_mode is recommended to be off

How to use it:
1) Set your settings in the "settings" section in the script
Be sure to set the NOAA zone and your email address.
Set all the settings for Email and Twitter, each method can be enabled or disabled.

2) Upload the php file to your web server

3) Test from a URL, see if you can see the output
Example: http://www.yoursite.com/rss-weather-alerter.php

see readme.txt for more info

Download:        
www.642weather.com/weather/scripts/noaa-top-weather-alerter.zip

Live Demo :      
www.642weather.com/weather/rss-weather-alerter.php
« Last Edit: June 14, 2010, 05:15:40 AM by MCHALLIS » Logged

MCHALLIS
Rain Maker
***
Offline Offline

Location: Long Beach, WA USA
Station Type: Davis VP2+
Posts: 1,997
Local Time: Thursday 11:26



WWW
« Reply #1 on: July 08, 2009, 10:22:36 PM »

It works like the NOAA RSS Top Warning 2009 PHP Script
http://www.weather-watch.com/smf/index.php/topic,40256.0.html

If there are multiple alerts, it will send you the one it thinks is most urgent.
Once it has an active alert it saves it in a cache file. Your script should run every 10 minutes on a schedule.
Every time the script runs it checks the cache file for the current alert status.
If the alert status changes again, to another warning or to no warning, then it will send another alert message indicating what it changed to.

You can have it email you.
You can have it auto post to Twitter.
You can email and twitter at the same time.

I have mine email my cell phone a text message.
Logged

MCHALLIS
Rain Maker
***
Offline Offline

Location: Long Beach, WA USA
Station Type: Davis VP2+
Posts: 1,997
Local Time: Thursday 11:26



WWW
« Reply #2 on: July 08, 2009, 10:24:15 PM »

I do not use Twitter yet. Can someone try it and tell me if the Twitter feature works?
Thanks, it works  Very Happy
« Last Edit: July 09, 2009, 01:20:36 AM by MCHALLIS » Logged

cnyweather
Professional Trophymaker!
Rain Maker
***
Offline Offline

Location: Rome, New York
Station Type: Davis Vantage Pro 2, Standard Radiation shield, Rainguage Heater, Boltek Lightning Detector, Quick Cam 9000
Posts: 1,210
Local Time: Thursday 14:26



WWW
« Reply #3 on: July 09, 2009, 12:45:19 AM »

http://www.twitter.com/cnyweather

The tiny URL went to your scripts. correct mike?


EDIT: my bad. didn't realize I could fix it. All set now.

Can you add multiple email addresses you think??
Code:
// be sure to set zone= to your actual zone
$Zone = 'NYZ037';

// email address to receive the messages
$email_address = 'weather@cnyweather.com';



THANKS MIKE!!  Cool
« Last Edit: July 09, 2009, 01:03:37 AM by cnyweather » Logged

Tony

CNYWeather.com
CWOP: CW2352
WeatherUnderground: KNYWESTM1


http://www.CNYWeather.com

I Make Trophies Too!
http://www.speedyawards.com
MCHALLIS
Rain Maker
***
Offline Offline

Location: Long Beach, WA USA
Station Type: Davis VP2+
Posts: 1,997
Local Time: Thursday 11:26



WWW
« Reply #4 on: July 09, 2009, 01:20:11 AM »

Yes you can send to multiple emails, both methods are acceptable

Code:
// email address to receive the messages
// Yes you can send to multiple emails, both methods are acceptable
// $email_address = 'user@example.com, anotheruser@example.com';
$email_address = 'you@yoursite.com';

I did find one small bug. (the twitter message did not have the zone title)

You could download the fix...
Version: 1.01 - 08-Jul-2009 - fix for adding zone name to the Alert message
« Last Edit: July 09, 2009, 01:24:21 AM by MCHALLIS » Logged

MCHALLIS
Rain Maker
***
Offline Offline

Location: Long Beach, WA USA
Station Type: Davis VP2+
Posts: 1,997
Local Time: Thursday 11:26



WWW
« Reply #5 on: July 09, 2009, 04:22:15 AM »

Version: 1.02 - 08-Jul-2009 - added global user agent string for outbound connections

Trying to add facebook, but the curl api I am using does not work  Mad
They no longer allow the CURL method.
I think I have found a way to update facebook status from the twitter tweet.
http://apps.facebook.com/selectivetwitter/
I need to investigate this more.

Did I mention... I do not use facebook or twitter yet?  Laughing
« Last Edit: July 09, 2009, 06:23:47 AM by MCHALLIS » Logged

MCHALLIS
Rain Maker
***
Offline Offline

Location: Long Beach, WA USA
Station Type: Davis VP2+
Posts: 1,997
Local Time: Thursday 11:26



WWW
« Reply #6 on: July 09, 2009, 08:12:53 PM »

Version: 1.03 - 09-Jul-2009 - added feature to customize the email subject and message
- improved web page details that are displayed.
Logged

Stronghurst
The Local Weather Source
Rain Maker
***
Offline Offline

Location: Stronghurst,IL USA
Station Type: Davis VP2 +
Posts: 1,685
Local Time: Thursday 13:26



WWW
« Reply #7 on: July 10, 2009, 01:26:08 AM »

Cool

Thank you
Mark
Logged

JtwnPaWeather
Johnstown PA Weather
Senior Forecaster
*
Online Online

Location: Johnstown, PA
Station Type: Davis Vantage Pro 2 Plus
Posts: 447
Local Time: Thursday 11:26



WWW
« Reply #8 on: July 10, 2009, 05:47:08 PM »

tested it out today both of them, Will be getting those online tonight sometime!
Logged


Lat:  40.295505  40:17:43.818N
Lon:  -078.905686  78:54:20.470W
MCHALLIS
Rain Maker
***
Offline Offline

Location: Long Beach, WA USA
Station Type: Davis VP2+
Posts: 1,997
Local Time: Thursday 11:26



WWW
« Reply #9 on: July 10, 2009, 07:05:13 PM »

Version: 1.04 - 10-Jul-2009 - more improvements to web page details that are displayed.
Logged

cnyweather
Professional Trophymaker!
Rain Maker
***
Offline Offline

Location: Rome, New York
Station Type: Davis Vantage Pro 2, Standard Radiation shield, Rainguage Heater, Boltek Lightning Detector, Quick Cam 9000
Posts: 1,210
Local Time: Thursday 14:26



WWW
« Reply #10 on: July 10, 2009, 07:53:37 PM »

Thanks for all the hard work mike!
Logged

Tony

CNYWeather.com
CWOP: CW2352
WeatherUnderground: KNYWESTM1


http://www.CNYWeather.com

I Make Trophies Too!
http://www.speedyawards.com
MCHALLIS
Rain Maker
***
Offline Offline

Location: Long Beach, WA USA
Station Type: Davis VP2+
Posts: 1,997
Local Time: Thursday 11:26



WWW
« Reply #11 on: July 10, 2009, 08:46:28 PM »

Version: 1.05 - 10-Jul-2009 - fixed bug where the email message had the zone title added twice.
Logged

cnyweather
Professional Trophymaker!
Rain Maker
***
Offline Offline

Location: Rome, New York
Station Type: Davis Vantage Pro 2, Standard Radiation shield, Rainguage Heater, Boltek Lightning Detector, Quick Cam 9000
Posts: 1,210
Local Time: Thursday 14:26



WWW
« Reply #12 on: July 10, 2009, 09:34:53 PM »

Dumb question Mike. Possible to only alert to certain things?

I seem to get a ton of Short Term Forecast and would like warnings/watches
to show only if possible
Logged

Tony

CNYWeather.com
CWOP: CW2352
WeatherUnderground: KNYWESTM1


http://www.CNYWeather.com

I Make Trophies Too!
http://www.speedyawards.com
MCHALLIS
Rain Maker
***
Offline Offline

Location: Long Beach, WA USA
Station Type: Davis VP2+
Posts: 1,997
Local Time: Thursday 11:26



WWW
« Reply #13 on: July 10, 2009, 09:46:15 PM »

Dumb question Mike. Possible to only alert to certain things?

I seem to get a ton of Short Term Forecast and would like warnings/watches
to show only if possible

OK, try this new version and let me know if it works.

Version: 1.06 - 10-Jul-2009 - added feature, new setting:
// some areas get too many Short Term Forecast and would like warnings/watches alerts only
$ignore_forecasts = false; // change to true to ignore "Short Term Forecast" alerts
Logged

cnyweather
Professional Trophymaker!
Rain Maker
***
Offline Offline

Location: Rome, New York
Station Type: Davis Vantage Pro 2, Standard Radiation shield, Rainguage Heater, Boltek Lightning Detector, Quick Cam 9000
Posts: 1,210
Local Time: Thursday 14:26



WWW
« Reply #14 on: July 10, 2009, 09:59:15 PM »

Beer's on me Mike. Installing it now.  Thank You!
Logged

Tony

CNYWeather.com
CWOP: CW2352
WeatherUnderground: KNYWESTM1


http://www.CNYWeather.com

I Make Trophies Too!
http://www.speedyawards.com
Pages: [1] 2 3 ... 13
  Print  |  « previous  |  next »  |  Go Up  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!