Author Topic: AerisWeather forecast in Saratoga template [Resolved]  (Read 365 times)

0 Members and 1 Guest are viewing this topic.

Offline Vasco

  • Senior Member
  • **
  • Posts: 85
    • PWS
AerisWeather forecast in Saratoga template [Resolved]
« on: January 30, 2023, 11:42:20 AM »
Decided to try Aeris forecast to be ready for the demise of Dark Sky, but I'm not getting anything. Changed Settings.php to use Aeris, entered access ID and secret key, entered forecast area and units, but nothing. Aeris website records API hits but no json in .../cache.

Note that I do have to use a proxy for cURL, but that is/has been working fine for the DS forecast and all the other cURLs in the template.

Also, everything works OK for Aeris forecast in my PWS_Dashboard (not currently selected).

What have I forgotten?
« Last Edit: January 30, 2023, 02:59:16 PM by Vasco »
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8823
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template
« Reply #1 on: January 30, 2023, 02:24:59 PM »
So, a couple of issues.  Running a view source on wxforecast.php?force=1 shows
Code: [Select]
<!-- AW-forecast.php (ML) Version 1.02 - 19-Jan-2022 on PHP 7.2.1 -->
<!-- temps in C -->
<!-- autoSetTemplate using narrow aspect. -->
<!-- loading from https://api.aerisapi.com/forecasts/?p=55.8983,-3.2077&format=json&filter=daynight,precise&limit=14&client_id=pMEv1Q5BisGq9AayV4u6b&client_secret=tXT0sXdZaPyB0vnIwBcO6EY1uJtEP9JszsKQMqsq. -->
<!-- curl fetching 'https://api.aerisapi.com/forecasts/?p=55.8983,-3.2077&format=json&filter=daynight,precise&limit=14&client_id=pMEv1Q5BisGq9AayV4u6b&client_secret=tXT0sXdZaPyB0vnIwBcO6EY1uJtEP9JszsKQMqsq' -->
<!-- HTTP stats:  RC=200 dest=192.168.252.254 port=3128 (from sce=192.168.252.43)
      Times: dns=0.000 conn=0.000 pxfer=0.026 get=0.009 total=0.036 secs -->
<!-- RC=200 Connection established, bytes=27050 -->
<!-- unable to open ./cache/AW-forecast-json-0-uk2-en.txt for writing. -->
<!-- using charsetInput='UTF-8' charsetOutput='ISO-8859-1' doIconv='1' doRTL='' -->
<!-- loading English period names -->
<!-- processing JSON entries for forecast -->
<!-- rawJSON size is 27011 bytes -->
<!-- AW_prepareJSON: Success. Valid UTF-8. -->
<!-- json_decode returns  - Syntax error, malformed JSON -->
So first, the cache file isn't writable.. that likely needs a permissions fix.  I suspect the second issue is due to proxy headers being returned, but can't validate until the cache file is writable and visible from 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 Vasco

  • Senior Member
  • **
  • Posts: 85
    • PWS
Re: AerisWeather forecast in Saratoga template
« Reply #2 on: January 30, 2023, 02:35:03 PM »
So first, the cache file isn't writable.. that likely needs a permissions fix.

I'll check; but I get DS-forecast-json, meteoalarm, UV forecast and metarcache OK?

Quote
I suspect the second issue is due to proxy headers being returned, but can't validate until the cache file is writable and visible from your website.

Ahhh, we've seen that before. . .

EDIT: /cache has 775. . .
« Last Edit: January 30, 2023, 02:39:29 PM by Vasco »
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8823
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template
« Reply #3 on: January 30, 2023, 02:41:46 PM »
And, you'll need to replace
Code: [Select]
  $i = strpos($html,"\r\n\r\n");
  $headers = substr($html,0,$i-1);
  $content = substr($html,$i+4);
with
Code: [Select]
  $stuff = explode("\r\n\r\n",$html); // maybe we have more than one header due to proxy redirects
  $content = (string)array_pop($stuff); // last one is the content
  $headers = (string)array_pop($stuff); // next-to-last-one is the headers
for the two instances.  That's what we did with DS-forecast.php :)
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 Vasco

  • Senior Member
  • **
  • Posts: 85
    • PWS
Re: AerisWeather forecast in Saratoga template
« Reply #4 on: January 30, 2023, 02:44:29 PM »
That's what we did with DS-forecast.php :)

I've just found the PM of 11/8/22. . . sorry, Ken  :oops:

EDIT: That's it! Thanks, Ken.
« Last Edit: January 30, 2023, 02:58:12 PM by Vasco »
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8823
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template
« Reply #5 on: January 30, 2023, 02:45:39 PM »
No problem!  I'll remember to update the source with the next update to AW-forecast.php as needed.
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 Vasco

  • Senior Member
  • **
  • Posts: 85
    • PWS
Re: AerisWeather forecast in Saratoga template
« Reply #6 on: January 30, 2023, 03:00:23 PM »
No problem!  I'll remember. . .

Wish I could say the same  :lol:
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline Vasco

  • Senior Member
  • **
  • Posts: 85
    • PWS
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #7 on: March 10, 2023, 01:18:36 PM »
Just been doing some updating, so I thought I would modify the new forecast scripts for my cURL proxy problems - just in case. Pleasantly surprised to find the $stuff mod already included in OWM-forecast.php  :-) . . . but not in PW and VC. I presume I would need to do them too?


 
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8823
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #8 on: March 10, 2023, 02:31:52 PM »
Yes, sorry.. forgot to retrofit those into the basic DW-forecast script adapted for PirateWeather and VisualCrossing displays.  For some reason, the OWM request ALWAYS had an internal redirect to the actual data, so had to apply the $stuff mod to make it work.
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