Author Topic: Installed DarkSky - now getting "Sorry.. the DarkSky forecast is not available."  (Read 625 times)

0 Members and 1 Guest are viewing this topic.

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3360
    • Emmett Weather
The subject says it all. I have entered my API Key but get the above message whenever I try to call DS-forecast.php. I have all of my desired locations setup in the array and the API Key in settings.php. Any thoughts or hints on how to solve this issue?
Don - W3DRM - Emmett, Idaho --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KBOI7
Davis Wireless VP2, WD 10.37s150,
StartWatch, VirtualVP, VPLive, Win10 Pro
--- Logitech HD Pro C920 webcam (off-line)
--- RIPE Atlas Probe - 32849

Offline Maumelle Weather

  • Forecaster
  • *****
  • Posts: 1824
    • Maumelle Weather
Hi Don,

In your DS-forecast.php script, please try removing the "//" from the script. It should look something like what you see below:

$DSforecasts = array(
 // Location|lat,long  (separated by | characters)
 'Saratoga, CA, USA|37.27465,-122.02295',
 'Auckland, NZ|-36.910,174.771', // Awhitu, Waiuku New Zealand
 'Assen, NL|53.02277,6.59037',
 'Blankenburg, DE|51.8089941,10.9080649',
 'Carcassonne, FR|43.2077801,2.2790407',
 'Braniewo, PL|54.3793635,19.7853585',
 'Omaha, NE, USA|41.19043,-96.13114',
 'Johanngeorgenstadt, DE|50.439339,12.706085',
 'Athens, GR|37.97830,23.715363',
 'Haifa, IL|32.7996029,34.9467358',
 'Minden - Johnson Lane|39.038556,-119.721083',
 'Minden - Downtown|38.95352 ,-119.76541757583618',
 'Gardnerville |38.94018,-119.7480583190918',
 'Gardnerville - Ranchos|38.89377,-119.74222183227539',
 'Genoa|38.94339,-119.75166320800781',
 'Sunridge|39.09540,-119.76531028747558',
 'South Lake Tahoe|38.94555863534868,-119.94860172271728',
 'Carson Pass|38.69470470625956,-119.98931765556335',
 'Red Lake|38.70132,-119.97124',
 'Blue Lake|38.62599040724098,-119.93456840515137',
 'Topaz Lake|38.6958,-119.543',
 'June Lake|37.7797,-119.074',
 'Lake Elmo, Minnesota|45.0103,-92.89288802242278',
 'San Jose, California|37.23346,-121.79916',
 'Morgan Hill, California|37.134251,-121.662172',
 'Half Moon Bay, California|37.4679,-122.4334',
 'Science Hill, Kentucky|37.20185,-84.72283',
 'Flagstaff, Arizona|35.198,-111.651',
 'Bozeman, Montana|45.693,-110.9836'
 );

John
GR2AE, GR3, Cumulus

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
The // in the declaration really has no effect.. it's a comment only :)

However, in Settings.php you have
Code: [Select]
$DSforecasts = array(
and that should be
Code: [Select]
$SITE['DSforecasts'] = array(
to pass the variables into the script correctly while DS-forecast.php is included in a wx...php page.
Also, you're missing a
Code: [Select]
$SITE['DSshowUnitsAs'] = 'us'; to have F,mph,inHg,in as the units.  The script's default is 'ca' for C,km/h,hPa,mm units.

The issue seems to be that the $SITE['DSAPIkey'] is arriving as null, so the return on the page looks like
Quote
<!-- DS-forecast.php (ML) Version 1.08 - 15-Feb-2019 on PHP 7.2.13 -->
<!-- temps in C -->
<!-- loading from https://api.darksky.net/forecast//37.27465,-122.02295?exclude=minutely,hourly&lang=en&units=ca. -->
<!-- curl fetching 'https://api.darksky.net/forecast//37.27465,-122.02295?exclude=minutely,hourly&lang=en&units=ca' -->
<!-- HTTP stats:  RC=404 dest=52.7.92.68 port=443 (from sce=74.208.58.124)
      Times: dns=0.060 conn=0.099 pxfer=0.181 get=0.040 total=0.220 secs -->
<!-- headers:
HTTP/1.1 404 Not Found
Date: Sun, 20 Jan 2019 00:51:51 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-store
X-Response-Time: 0.134ms
Vary: Accept-Encoding
 -->
<!-- RC=404 Not Found, bytes=225 -->
<!-- bad return from https://api.darksky.net/forecast//37.27465,-122.02295?exclude=minutely,hourly&lang=en&units=ca
HTTP/1.1 404 Not Found
Date: Sun, 20 Jan 2019 00:51:51 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-store
X-Response-Time: 0.134ms
Vary: Accept-Encoding

Not Found

 -->
<!-- cache ./DS-forecast-json-0-ca-en.txt missing or contains invalid contents -->
<p>Sorry.. the DarkSky forecast is not available.</p>
I see in Settings.php you do have a $SITE['DSAPIkey'] setting and what looks like a valid key.  Why it ends up in the request URL as // instead of /<the-api-key>/ I don't know...

When I try the URL in the browser with your API key inserted, it works fine, so the API key is good.

D'Oh.. You can't run DS-forecast.php itself without configuring the $DSAPIkey,$DSforecasts,$showUnitsAs variables.  If you run it in wxforecast.php, then the $SITE variables are read.  In the DS-forecast.php script on your site, you've commented out
Code: [Select]
// $DSAPIkey = 'specify-for-standalone-use-here'; // use this only for standalone / non-template use
so $DSAPIkey is a null string, ergo.. no key is used.

So.. to fix to have DS-forecast.php run standalone as you're doing, configure the three above variables in the script itself.

Best regards,
Ken
« Last Edit: January 19, 2019, 08:04:00 PM by saratogaWX »
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: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
It may be easier to copy wxnewpage.php to wxdsforecast.php and replace the middle section with
Code: [Select]
<div id="main-copy">
         <?php 
 $doIncludeDS  true// handle DS-forecast include 
 include_once('DS-forecast.php'); ?>


</div><!-- end main-copy -->

and make your Settings.php corrections as noted in the above post.  Then you can add wxdsforecast.php to your menu and it should work fine.
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 W3DRM

  • Forecaster
  • *****
  • Posts: 3360
    • Emmett Weather
Thanks guys! I haven't touched my website for quite a while and thought I would start working on some things. That's when I found the DarkSky post and started putting that together. I want it to be part of the ajax system along with my other stuff. Will work on it tomorrow afternoon when I have some free time (ha, that's a joke!).

As always, the members of this forum are simply the best and I really appreciate the help.  =D&gt;
Don - W3DRM - Emmett, Idaho --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KBOI7
Davis Wireless VP2, WD 10.37s150,
StartWatch, VirtualVP, VPLive, Win10 Pro
--- Logitech HD Pro C920 webcam (off-line)
--- RIPE Atlas Probe - 32849

Offline Theo

  • Senior Member
  • **
  • Posts: 80
I have been playing along at home and I got it working.  It is important that your gps coordinates are formatted correctly on your DSforecasts section.  I had a stray "." and it gave me the same error message.   I did note that if you only have one forecast defined, DS-forecast.php throws the following error:

[Sun Jan 20 00:18:33.626110 2019] [:error] [pid 4581] [client x.x.x.x:52867] PHP Notice:  Undefined variable: RTLopt in /WWW/zzzz.com/html/weather/DS-forecast.php on line 754, referer: https://www.zzzz.com/weather/wxdsforecast.php
[Sun Jan 20 00:18:33.626194 2019] [:error] [pid 4581] [client x.x.x.x:52867] PHP Notice:  Undefined variable: RTLopt in /WWW/zzzz.com/html/weather/DS-forecast.php on line 759, referer: https://www.zzzz.com/weather/wxdsforecast.php

I added another forecast location and that cleared the error.


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
I have been playing along at home and I got it working.  It is important that your gps coordinates are formatted correctly on your DSforecasts section.  I had a stray "." and it gave me the same error message.   I did note that if you only have one forecast defined, DS-forecast.php throws the following error:

[Sun Jan 20 00:18:33.626110 2019] [:error] [pid 4581] [client x.x.x.x:52867] PHP Notice:  Undefined variable: RTLopt in /WWW/zzzz.com/html/weather/DS-forecast.php on line 754, referer: https://www.zzzz.com/weather/wxdsforecast.php
[Sun Jan 20 00:18:33.626194 2019] [:error] [pid 4581] [client x.x.x.x:52867] PHP Notice:  Undefined variable: RTLopt in /WWW/zzzz.com/html/weather/DS-forecast.php on line 759, referer: https://www.zzzz.com/weather/wxdsforecast.php

I added another forecast location and that cleared the error.


Thanks for spotting that.. the definition for $RTLopt as placed inside the menu processing.. I'll move it so it's always processed irrespective of number of locations specified.

BTW.. I'm working on adding the (optional) hourly forecast to the script.
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: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Finished the hourly forecast addition and the above fix.

See https://www.wxforum.net/index.php?topic=35539.msg368949#msg368949
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

 

anything