What does it do?
Ever want to receive current weather conditions by cell phone, blackberry, Twitter, or email? Now you can.
This PHP script is used to check the Weather Display Conditions on a timed schedule,
then send a message.
Uses Weather Display Conditions data from your own personal weather station’s testtags.php.
The message is short enough to send to twitter, a cell phone, blackberry, or email.
Supports sending messages by Email and Twitter, each method can be enabled or disabled.
Messages can be customized in the script settings.
What do I need?
PHP 5 with CURL support is required
… personal weather station with weather-display software uploading testtags.php to your web site
… 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 1 hour.
… your PHP server MUST allow PHP scripts permission to write files.
… PHP safe_mode is recommended to be off
How to use it:
Set your settings in the “settings” of the PHP script.
Be sure to set your email address and the optional twitter user password.
Also set the settings for Email and Twitter to customize the messages, each method can be enabled or disabled.
Upload this php file to your web server
Test from a URL, see if you can see the HTML output
Example: http://www.yoursite.com/wd-conditions-messenger.php
After testing, you can move it to a private non-public web server folder.
Warning: it is recommended that you put the PHP file in a non-public www directory!
because you do not want people clicking the URL and flooding you with emails and twitters!!
If you put it in a non-public www directory, then the only way you can call it is from a cron job
There is a flood filter setting that will prevent the flood problem and allow you to have it in a public folder,
but make sure you test it first, don’t just “set it and forget it”.
It is recommended that you test an email or twitter to make sure you will receive one.
Schedule automatic timed updates
see readme.txt for more info
I wish I could get the wind and the gust rounded without a decimal place.
I thought that normally there should not be decimals on mph wind units anyway?
Just a side note, If you use a Davis VP 2+ and want to use the info that comes from the solar info, just replace $weathercond with $Currentsolardescription as the $weathercond is based on the metar for the airport you are using. and using the $Currentsolardescription will use the info that is coming from your unit.
// array of words to shorten, but only when the twitter message is more than 140 characters.
// array is formatted is like this: 'Long Word' => 'Short Word',
// you can add or comment out lines from this array as you like
// the shorten_twitter function will loop through the word replacements one at a time and break early
// if the message is shortened enough.
$twitter_shorten = array(
'Showers' => 'Shwrs',
'Rain' => 'Rn',
'Chance' => 'Chce',
'Partly' => 'Ptly',
'Cloudy' => 'Cldy',
'Forecast' => 'Frcst',
'Night Time/' => '',
'Cloudy with clear patches' => 'Ptly Cldy',
);
I switched on $Currentsolardescription my demo.
I got busy so I cannot release it today.
No problem, I was tinkering with the script till about 3am lol. Since i am a night owl all the time. and was tweaking the settings. Just have to watch for the longest one of them all i seen so far and that is the: Night Time/Dry/Cloudy with clear patches
Version: 1.03 - 17-Jul-2009 - improved shorten_twitter function
added configurable array of shorten_twitter words to settings.
changed current condition variable to use $Currentsolardescription instead of $weathercond,
this can be reversed on about line 256:
// uncomment only one of these two condition tags
$sCond = $Currentsolardescription; // current condition: Dry/Cloudy
//$sCond = $weathercond; // current condition: Dry
Mike works great here. Love the idea for the lines to strip anything that is above 140 for twitter.
As for the email via text to a cell phone took notice they also have a limit. So i used what you had in there and have the email set for 120 chars. So both work.
Did notice that the Cloudy with clear patches still shows up. But i was working on it, when it went overcast just my luck lol. and noticed that it adds a extra space after the $sCond, so you end up with Cloudy with clear patches , Temp.
Also in the Array you have ‘Night Time/’ => ‘’, twice is this correct? wasn’t sure.
Also seen that it seems wd is adding it’s own little space in there, as i did have $sCond, in there and now with a update shows Night Time/Dry/mostly cloudy - , Temp 61F
Yea i like tinkering with things. and i am up 1/2 the night lol