A fix for “failed to open stream” w/WeatherIcon 2.0
With new WP, there’s a built-in function to retrieve a given URI. My quick fix was to use that, as it will use fopen if available, else use curl.
look for the lines:
$host = 'weather.noaa.gov';
$location = "/pub/data/observations/metar/stations/$station.TXT";
You’ll be replacing all the code AFTER those two variables, all the way down to (but not including):
if ($fp = fopen($metar_cache, "w"))
The new, replacement quick hack retrieval code I used is:
$metar = wp_remote_fopen('http://'.$host.$location);
$offset = strpos($metar, $station); // better be!
if ($offset===FALSE) $metar = false;
else $metar = substr($metar, $offset);
Seems to be working well for me so far at home, though my host still doesn’t like curl any better than fopen/fsockopen.
THIS IS A HACK. YMMV. If you aren’t having problems, I’d wait until it can be tested further and rolled into a ‘proper’ bulletproof solution in a main release…
- The topic ‘A fix for “failed to open stream” w/WeatherIcon 2.0’ is closed to new replies.