Trixology

WeatherCat => WeatherCat Web Templates => Topic started by: saratogaWX on November 01, 2014, 12:18:16 AM

Title: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: saratogaWX on November 01, 2014, 12:18:16 AM
It was about a 60% rewrite of the old script to allow use/cache of the WeatherUnderground API calls for forecast info, but it's now finished.

Before you install, make sure you have registered for a Developer API key at http://www.wunderground.com/weather/api/
You'll need to be a member of WeatherUnderground (but you already should be a member if you were using the prior script).  Get your key from the page listed above.

Standalone users: Download from the script page (http://saratoga-weather.org/scripts-WUforecast.php#WUforecast) which has updated documentation.
Enter your key in
Code: [Select]
$WUAPIkey = 'specify-for-standalone-use-here'; in the script.

Saratoga template users: Use the Updates tool (http://saratoga-weather.org/wxtemplates/updates.php) to get your update. (Base-World, Plugin-*, 31-Oct-2014)
Add a line to your Settings.php with
Code: [Select]
$SITE['WUAPIkey'] = 'specify-your-api-key-here';
then save and upload Settings.php, then upload the WU-forecast.php.

Major changes:
1) the script will parse your existing WU page URLs and should create valid API query strings, so your existing settings should work as before -- the data will be from the API instead of the page being scraped.
2) the cache file names have changed to add a -json in them so there is no interference with old page cache files.
3) you can now select for metric (C,km/s,hPa,mm) or imperial (F,mph,inHg,in) units for the forecast icons and text.  Sorry, there is no mix-n-match capability.  It is all of one or the other.
4) the day name issue should be fully resolved .. at least it was when I checked tonight.
5) the Africaans, Gaelic and Bulgarian forecasts are in English .. it's a WU issue as the script does no translations, but
  relies on WU for all of that.

Enjoy...

Best regards,
Ken
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: jf-i2r on November 01, 2014, 09:04:20 AM
thanks Ken all is ok for me  [tup]
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: saratogaWX on November 01, 2014, 02:09:43 PM
I found that I had omitted the logic for standalone use non-English language default selection ..

The V3.01 script is now available, and if $lang= is set in the script, that will be the default language for all forecasts.

After the update of the script, the cache may still hold the old English .. add ?force=1 to the URL to cause the cache to refresh with the new default language.

Best regards,
Ken
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: jf-i2r on November 01, 2014, 03:42:53 PM
hi ken

$lang = 'fr';   // défaut language

 [tup]

cheers
jean fred
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: wurzelmac on November 01, 2014, 08:14:32 PM
Thank you, Ken - played around with this for me "new toy" today a bit and I am impressed what someone could do with your script and a little html-experience (http://wetter.unterwurzacher.at/WU-forecast.php)!

Cheers,
Reinhard
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: saratogaWX on November 01, 2014, 10:29:23 PM
Thanks for the kind words, Reinhard :)

Some problems were encountered using WU URL formats I was not aware of before...  I've added handling of those types into the V3.02 version of the script.

Now URLs with queries like:

/q/locid:UKEN1390
/cgi-bin/findweather/getForecast?query=zmw:00000.1.03749
/q/zmw:00000.6.06280
/US/HI/Honolulu.html
/global/ML.html

are handled now too.

Best regards,
Ken
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: jf-i2r on November 02, 2014, 08:17:26 AM
hi ken

no problems for me and WU URL and V3.01

http://www.jf-i2r.com/wxforecast.php

best regards
jean fred
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: marzio2515 on January 12, 2015, 07:03:05 PM
Hi Guys...
i'm having some troubles with WU-forecast.php, in the main screen i got the errors show in the attached files...
that's what  i did
1) edit the WU-forecast and setting this line to point to my WU station address on Weather Underground:
                        $WU_URL = 'http://www.wunderground.com/q/zmw:00000.47.16179';(that's my station address on W.U web site)

2)edit Settings.php as the  following:

               $SITE['fcsturlWU']= 'http://www.wunderground.com/q/zmw:00000.47.16179'; // Urbania, Italy(again my W.U. Station Address)
               
               $SITE['WUforecasts'] = array(
                 // Location|forecast-URL  (separated by | characters
               'Urbania|http://www.wunderground.com/q/zmw:00000.47.16179', // Urbania, Italy
               etc... etc.... the other town and county .... etc....
                   )
in the array i put my station as the first entry

but anyway i can't retrieve weather forecast for my location... instead i got the error shown in the attached file

i'm using WeatherCat 2.0.2 and the last World-Base script and plugin (the WU-forecast is the 3.0.2)

any help/suggestion ???
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: marzio2515 on January 12, 2015, 07:06:21 PM
i forgot telling i also add these line to my Settings.php
$SITE['WUAPIkey'] = '9ed97e8648b81534';

any help is appreciate...

Thanks
Marzio
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: saratogaWX on January 12, 2015, 07:10:01 PM
Marzio,

To diagnose the issue, it would be really helpful to have the URL to your website.

Best regards,
Ken
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: marzio2515 on January 12, 2015, 08:03:37 PM
first:
http://www.urbaniameteo.it

then:
choose : "Dati Completi" on the left hand menu and u will be on the saratoga main screen (sometimes u got the error on this main page)

otherwise you can choose on the left "Nav Menu" -->"previsioni & dettagli" --> "dettagli previsionali" and you can see the error

thanks
Marzio
 
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: saratogaWX on January 12, 2015, 08:13:25 PM
WeatherUnderground is responding to your query with
Code: [Select]
{
  "response": {
  "version":"0.1",
  "termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
  "features": {
  }
,
"error": {
"type": "keynotfound"
,"description": "this key does not exist"
}
}
}

I suspect that the WUAPIkey is not correct and that is why you're not getting a forecast.
Title: Re: WU-forecast.php V3.00 available -- requires WU API key to operate
Post by: marzio2515 on January 12, 2015, 08:35:00 PM
Thanks Ken, now it works.... i updated my key on WU web site!!

Thanks Again...!!

Marzio