Forums

GetWeather returns "Weather Not Available (Read Error)" (4 posts)

  1. btsixer
    Member
    Posted 6 years ago #

    Having trouble with install of getweather plug-in.

    Here is the entire display when I call "getweather('75075')":

    Warning: fopen(http://xoap.weather.com/weather/local/75075?cc=*&dayf=1&unit=s) [function.fopen]: failed to open stream: Connection refused in /var/www/html/wp-content/plugins/getweather.php on line 122

    Weather Not Available (Read Error)

    However, if I go to:

    http://xoap.weather.com/weather/local/75075?cc=*&dayf=1&unit=s

    it returns the XML data. So I don't know what the read error is. Any ideas?

  2. btsixer
    Member
    Posted 6 years ago #

    Kind bump..

  3. Lorelle
    Member
    Posted 6 years ago #

    Do check with the plugin author to make sure that the plugin has been upgraded to be compatible with your version of WordPress. Some of these have not been.

  4. aklamo
    Member
    Posted 5 years ago #

    It might be that fopen() is not allowed on your server for security. You use a cURL solution instead. For example, you can replace the following section

    $file = "http://xoap.weather.com/weather/local/$citycode?cc=*&dayf=1&unit=$measurement_system";
    $xml_parser = xml_parser_create();

    if (!($fp = fopen($file, "r"))) {
    return("

  5. Weather Not Available (Read Error)
  6. ");
    }

    with

    $file = "http://xoap.weather.com/weather/local/$citycode?cc=*&dayf=1&unit=$measurement_system";
    $ch = curl_init($file);
    $fp = @fopen("temp.xml", "w");
    curl_setopt($ch, CURLOPT_FILE, $fp);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_exec($ch);
    curl_close($ch);
    $file = "temp.xml";
    $fp = fopen($file, "r");
    $xml_parser = xml_parser_create();

    I've got it working on a dreamhost server: http://www.innatonancock.com

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags