how to - Burnham-on

advertisement
Put the forcast text in the public files of your web server
Remember to set all files to read/write or they will not work
I left my stuff in there so you can see what you need and examples just overight
them
open the fetch_forcast.php and change the URL of the BBC 3 day weather forcast
by going to http://www.bbc.co.uk/weather/
enter your nearest town and enter, then click 5 day forcast and on that page
click rss 3 day forecast feed then copy the URL from the URL bar and put this in
the fetch_forecast.php LINE 176 this is mine------$xml =
file_get_contents("http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/3794.xml");
Thats it for changing anything.
Once you've got that all working correctly, all you need to do is set up a cron
job or scheduled task on your server to run the php file four times a day, which
will replace the last weather forecast image with the new one.
The image is called weather_sig.png this is created from the blank_sig.png so
just create your own blank_sig.png using a graphics programme (Gimp etc) and
create your own template to say what you want.Just use the same dims or you will
have to play with positions etc of the icons or weather forecast.
And last but not least this forecast is still in testing all the icons may not
line up with the forecast wording (cos we have had no crap weather since I
started running this script). So what will happen is that you will see a
forecast but no icon above. Its easy to fix just go in the fetch_forecast.php
and look here, so for example if the forecast says "sunny" then it should show
the sunny.png. To change, either add another line like so then if the forcast
says bad weather change the "case" to "bad weather" and the return to "bad
weather.png" there should at least be an icon to match in the folder,or send me
an email for some help :)
example for an update
--------------------------------------------------case "bad weather":
return "icons/bad weather.png";
break;
--------------------------------------------------this is in the script already may not be entirely correct!!
--------------------------------------------------function typeToImageName($sWeatherType){
switch($sWeatherType){
case "sunny":
return "icons/sunny.png";
break;
case "sunny intervals":
return "icons/sunny_intervals.png";
break;
case "cloudy":
return "icons/cloudy.png";
break;
case "light showers":
return "icons/light_showers.png";
break;
case "heavy showers":
return "icons/heavy_showers.png";
break;
case "light rain":
return "icons/light_rain.png";
break;
case "heavy rain":
return "icons/heavy_rain.png";
break;
case "thundery":
return "icons/thundery.png";
break;
case "sleet":
return "icons/sleet.png";
break;
case "hail":
return "icons/hail.png";
break;
case "snow":
return "icons/snow.png";
break;
case "fog":
return "icons/fog.png";
break;
case "drizzle":
return "icons/drizzle.png";
break;
}
Download