YR.NO forecast PHP-script - updated

As so many ask for it, updated my forecast-script what use the free data from yr.no. :smiley: (Thanks to Jim Mcmurry for kicking me to get it done :))
It shows the 10-day forecast using the free data from yr.no. There are currently over 7 million of citys to choose from.

New:

  • Multicity-pulldown with ablity for multiple country’s too :slight_smile:
    There are 17 citys as sample (my array) with 16 finnish and 1 swedish city
  • Configurable settings
    *Temp as C or F
    *Rain as mm or in
    *Baro as in or hPa
    *wind as m/s, km/h or mph
  • Added yr.no-logo & headerimage for the tables
  • Changed to the avanced meteogram
  • Works both stand-alone and as an include
    Added in update:
  • Option for multilanguage using the $lang-parameter
  • Autodetecting if standalone or include
  • W3 valid
  • Added css- and lang-files
  • Remade the city-pulldown for easier customation
    Update 2:
  • Pulldown is now optional

Download: http://www.nordicweather.net/yr.no.tar.gz

See it in action: here

Install as include on webpage:

  • Add this to the of the page:
<link type="text/css" rel="stylesheet" href="yrno_css.css" />
  • Where you want it to appear add:
<?php
include '/path/to/the/script';
?>

Remember to create the cachefolder for it and to chmod it so the script can write to it. Default foldername is cache.

To add new language:
In yr_lang.php, just copy the part where $lang == “en” and add a new set and then translate it.

EDIT: Instructions and package updated.

Cheers
Henkka


Something I’m doing this script does not like! #-o

http://stillweather.com/yr_xml.php

Im getting the samething here.

And this part has me stumped. i see alot of finland in their. Do we have to put United_States in place of where it says Finland in all of them spaces?



/ Pulldown-settings
// This is the tricky part... :p
// To get right settings here go to yr.no and find city you want and take the URL of it, ex.
// http://www.yr.no/place/Finland/Western_Finland/Halikko/
// - Finland is $country
// - Western_Finland is $region
// - Halikko is $city

$country = array
('United_States','Finland','Finland','Finland','Finland','Finland','Finland','Finland',
'Finland','Finland','Finland','Finland','Finland','Finland','Finland','Finland','Sweden');

$region = array('Washington','Western_Finland','Western_Finland','Southern_Finland','H

Just below those arrays is a default number that is 2. Make that 0 and it’ll use you location info. I also had to work on the paths to the images, so you may have to do that too.

  • Jim
Im getting the samething here. And this part has me stumped. i see alot of finland in their. Do we have to put United_States in place of where it says Finland in all of them spaces?

Few things guys:

  1. cache-folder. Check that setting and also check the folder is there and writeble so the script can write the xml to it, thats why you don’t see anything. If you check the source-code there are a
<!--Unable to write cache cache/Turku.xml -->

in this case, create a cache-dir in root-dir, chmod it to ex 766 and it should work
This message will disappear once it can write the file.

  1. For the arrays:
    I. go to yr.no
    II. search for city of choice and take the url of it
    Example my place have this url: http://www.yr.no/place/Finland/Western_Finland/Halikko/
    So Finland comes in $country
    Western_Finland in $region
    and Halikko in $citys
    all as they are in the url, if there are a “_” then it should be also in the array.

Still no luck. I understand the arrays, but the script seems to get stuck. I have a file called cache.xml with full permissions on my web site and changed the cache settings to 30 just to try to get it going.

Jack

You should have a folder called cache not a file :wink:

EDIT:
Firewall:
Your page works now, at least when tested with ex. Helsinki :slight_smile:
Then its just the timetaker to figure out the urls for citys you want in the list :wink:

You should have a folder called cache not a file

That was my issue! Thanks Henkka works great now!

Jack

Here it is with my CSS…Branford CT, Weather, News and More

OK…so how did you get it working?..lol

i have a folder called cache and set to 766

Mark,

Check your “region” and “city” I think you have them reversed.

Jack

i have…

$region = array(‘Washington’
$citys = array(‘Seattle’,

@Jack: Looking great!

@ALITTLE: Your page still says it can’t write to the cache-folder?..Is it in root (or from wherever you run the page), ex. in same folder where wxtest.php is located?
You can allways test with one of the finnish citys to see if works, thats why I left them there.

yes, the folder is in my default /web directory, same place where the test page is. I do have the script in another folder. i wonder if the path to the cache file needs changed. Ive tried changing it, but nothing has worked.

$cachedir = “cache/”;

yes, the folder is in my default /web directory, same place where the test page is. I do have the script in another folder. i wonder if the path to the cache file needs changed. Ive tried changing it, but nothing has worked.

$cachedir = “cache/”;

Works now :slight_smile:

it was a path problem. Thanks for the help

Henka, thanks for this!!!

:thumbright:

just trying to figure out where the rest of the icons are and why they wont load

http://www.cnyweather.com/yr_xml.php

I had to change the path to them in a few places in my script. Just search for img and you should find them.

  • Jim

I have it setup here: http://www.harpersferry-weather.com/wxyr_no.php
How can we get the meteogram to read english units instead of metric?

John

I don’t think you can, John, as the Metrogram is taken direct from the YR.no website.

Thanks Henkka, I’ve updated to the latest version and the alternate cities make a nice addition. :smiley:

Will fix that imagefolder problem, just forgot that :slight_smile:

How can we get the meteogram to read english units instead of metric?

Yes, it come directly from yr.no and I haven’t at least yet found any meteogram using F.

Henkka