How To PHP Upload Your Web Cam Image to Weatherunderground
This is a tutorial on how I upload my web cam image to WeatherUnderground. It is probably too complicated for many average users. If you already have a personal weather station, Weather-Display Software, a web cam, and a weather web site, then this tutorial might look interesting to you.
Step 1) I am assuming you already completed the
6 steps of Image Overlay Text
and now have an image at
http://www.yourwebsite.com/webcamimage.jpg
Step 2) Create a WebCam account at
wunderground.com
Step 3) Install my Weather Underground Web Cam Image Upload PHP Script:
Just
download the file,
name it php-cam-image-upload.php
Adjust a few settings at the top just like this:
$ftp_server = 'webcam.wunderground.com';
$ftp_username = 'YOUR_WU_USERNAME'; # change this to your WU username
$ftp_password = 'YOUR_WU_PASSWORD'; # change this to your WU password
$source_file = '/path/to/your/webcamimage.jpg';
Step 4) Test from a URL, you will see "upload success" or "upload failed"
Example: http://www.yoursite.com/php-cam-image-upload.php
Step 5) Schedule automatic timed updates: There are a few ways to do this, I use method 2
Method 1: If you already have weather-display software click on
Control Panel | FTP & Connections | HTTP Download tab
Click on #1,#2 or #3 setup button | switch on the button for "downloads on |
enter your php-cam-image-upload.php url in the box called "URL of file to be downloaded" |
click "add to list" | check the tick that says "Tick if text file" |
enter php-cam-image-upload.txt in the box that says "Local filename to be downloaded" |
click "add to list" | click "download every 5 minutes" | click "save now" | click OK
Method 2: Schedule a server cron job to run this php file every 5 minutes.
(this example requires shell access, there are other ways using control panels, ask your web host how to use cron)
Example using crontab -e: (first change /path/to/ to your server path)
2,7,12,17,22,27,32,37,42,47,52,57 * * * * php /path/to/php-cam-image-upload.php 2>&1 > /dev/null
note: my cam uploads on the 5's,
my text overlay cron runs a minute later on the 1 and 6,
this cron runs a min later on the 2 and 7
Simple guide to crontab usage at
cron - Wikipedia
Method 3: Use
Scheduled HTTP Request - Windows Task Scheduler
to make a HTTP Request to the URL http://www.yourwebsite.com/php-cam-image-upload.php every 5 minutes
Discuss this tutorial here | WunderCam Directory | More Weather PHP Scripts
Gratuity
This php code provided "as is," and Long Beach Weather (Michael Challis) disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. Use of this code signifies your acceptance.



