Author Topic: New OpenWeatherMap and VisualCrossing weather forecast scripts available  (Read 834 times)

0 Members and 1 Guest are viewing this topic.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8884
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
It's been a busy late Jan/early Feb with coding to add two more sources for international, multilingual forecasts:

OpenWeatherMap (https://openweathermap.org) and VisualCrossing (https://visualcrossing.com).  Both provide limited-use free API keys available.

Both providers only give one daily icon per-day for their forecasts, (so no day/night displays).
OpenWeatherMap does provide full translations for forecast text.
VisualCrossing provides de (German), en (English), es (Spanish), fi (Finnish), fr (French), it (Italian), pt (Portuguese), ru (Russian), nl (Netherlands), sr (Serbian). Other languages will return in English.

The OpenWeatherMap script page is here and on GitHub here.
The VisualCrossing script page is here and on GitHub here.

The scripts are included in the Base-World template using the update tool with query Base-World,*.Plugin, 07-Feb-2023

Note that Base-* templates also get updated ajax-dashboard.php V1.33, wxforecast.php V1.06 and check-fetch-times.php V1.49 to support the new scripts.

For a DarkSky replacement, I'd suggest using the OpenWeatherMap one as it has the most complete translations for multilingual use.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Lee10

  • Member
  • *
  • Posts: 18
This is a fantastic script and thanks for all the hard work.

However, I have problems using it as a stand-alone script. When I put in my API key in it comes out up as error and the forecast becomes invalid.

"Sorry.. the DarkSky forecast is not available" is what I get.

Regards

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8884
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Which script are you using?  What is the URL to the configured script on your website?
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Lee10

  • Member
  • *
  • Posts: 18
Thanks for your reply. I am using the OWM one and the URL is:

http://lee10.hyperphp.com/OWM-forecast.php

it says Dark Sky but I am using the OWM API key

Regards

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8884
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Doing a view-source: on your OWM-forecast.php page shows
Quote
<!-- OWM-forecast.php (ML) Version 2.01 - 07-Feb-2023 on PHP 7.4.8 -->
<!-- temps in C -->
<!-- loading from https://api.openweathermap.org/data/3.0/onecall?lat=37.27465&lon=-122.02295&exclude=minutely&units=metric&lang=en&appid={redacted}. -->
<!-- curl fetching 'https://api.openweathermap.org/data/3.0/onecall?lat=37.27465&lon=-122.02295&exclude=minutely&units=metric&lang=en&appid={redacted}' -->
<!-- HTTP stats:  RC=401 dest=82.196.7.246 port=443 (from sce=185.27.134.63)
      Times: dns=0.002 conn=0.017 pxfer=0.066 get=0.017 total=0.084 secs -->
<!-- headers:
HTTP/1.1 401 Unauthorized
Server: openresty
Date: Mon, 06 Mar 2023 16:31:47 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 338
Connection: keep-alive
X-Cache-Key: /data/3.0/onecall?exclude=minutely&lang=en&lat=37.27&lon=-122.02&units=metric
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST
 -->
<!-- RC=401 Unauthorized, bytes=720 -->
<!-- bad return from https://api.openweathermap.org/data/3.0/onecall?lat=37.27465&lon=-122.02295&exclude=minutely&units=metric&lang=en&appid={redacted}
HTTP/1.1 401 Unauthorized
Server: openresty
Date: Mon, 06 Mar 2023 16:31:47 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 338
Connection: keep-alive
X-Cache-Key: /data/3.0/onecall?exclude=minutely&lang=en&lat=37.27&lon=-122.02&units=metric
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST

{"cod":401, "message": "Please note that using One Call 3.0 requires a separate subscription to the One Call by Call plan. Learn more here https://openweathermap.org/price. If you have a valid subscription to the One Call by Call plan, but still receive this error, then please see https://openweathermap.org/faq#error401 for more info."}
 -->
<!-- cache ./OWM-forecast-json-0-metric-en.txt missing or contains invalid contents -->
<p>Sorry.. the DarkSky forecast is not available.</p>
The 'DarkSky' should read 'OpenWeatherMap' .. sorry about that.

The JSON returned indicates that your key is valid, but you have not subscribed to the One Call by Call plan for your key.  Do the subscription, and the API should return data for the forecast.

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8884
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
I've released an update to OWM-forecast.php V2.02 to show the error message clearly when a non-successful API query happens.

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Lee10

  • Member
  • *
  • Posts: 18
Thanks for your reply. Did not notice about the One by One subscription I was on the free key.