WordPress.org

Ready to get started?Download WordPress

Forums

WP Cloudy
[resolved] Error simplexml_load_file on shared hosting (11 posts)

  1. Walter Bishop
    Member
    Posted 6 months ago #

    Hello,
    I am getting the simplexml_load_file error. I researched it and found the allow_url_fopen directive fix, but I am using shared hosting and cannot change my PHP directives. The webdev experts I read from claimed that using curl instead would fix this problem, and also that using fopen to pull in external files was not secure and that curl should be used instead anyway.

    Could you change your code to use curl instead, to better support shared hosting users? Or perhaps send the required code changes to me at least? I could not figure out how to code all those changes myself.

    Thank you for your time

    https://wordpress.org/plugins/wp-cloudy/

  2. rainbowgeek
    Member
    Plugin Author

    Posted 6 months ago #

    Hi,
    can you post a screenshot of your problem please?

    Thank you

  3. kevin9027
    Member
    Posted 6 months ago #

    Got into the office this morning with an error on one of our sites concerning simplexml_load_file too. It was working fine last week. There weren't any changes made to the server and it is still working fine on the dev server.

    Here's the error:

    Warning: simplexml_load_file(): http://api.openweathermap.org/data/2.5/forecast?q=Grand%20Haven%2C%20MI%2Cusa&mode=xml&units=imperial&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=en:1: parser error : Start tag expected, '<' not found in /var/www/vhost/ourdomain.org/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1390 Warning: simplexml_load_file(): {"message":"","cod":"404"} in /var/www/vhost/ourdomain.org/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1390 Warning: simplexml_load_file(): ^ in /var/www/vhost/ourdomain.org/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1390

  4. kevin9027
    Member
    Posted 6 months ago #

    Okay. So, it appears your service was unavailable this morning (and apparently part of yesterday too).
    Since having your service go down and send back a 404 throws a GIANT error on the page, I think we'll have to discontinue using it. Not having a temp, or missing some of the info is one thing, but a wall of error text on an api 404 isn't something we can have. If you have a way to get around this, please let me know.

    Thank you for your time and efforts on a great looking plugin.

  5. rainbowgeek
    Member
    Plugin Author

    Posted 6 months ago #

    Hi,
    this error happens when openweathermap.org (the service that provides weather) doesn't load. Free version provides availability from 95% to 99,5%. (http://openweathermap.com/price)

    However, I am currently developing a caching system to avoid such problems and gain speed.

    Thanks.

  6. kevin9027
    Member
    Posted 6 months ago #

    thanks for the reply.
    even just a message that's editable in the php or something whenever there isn't a response. It never occurred to us that having the weather service down would throw a wall of error code on our client's homepage, because all weather service apis are unavailable from time to time.

    At any rate, it looks great. Clean and sexy.
    Thanks.

  7. scald
    Member
    Posted 6 months ago #

    I came across this error after exporting an existing site to a new multisite environment. The reason I got the error was because my short code referred to the ID of the Weather post from the old environment, but when I imported the posts, the ID's were changed.

  8. Mr Press
    Member
    Posted 6 months ago #

    If problems persist you can use cURL, which is a better idea anyway. Replace the following lines in wpcloudy.php:

    $myweather = simplexml_load_file("http://api.openweathermap.org/data/2.5/forecast?q=$wpcloudy_city,$wpcloudy_country_code&mode=xml&units=$wpcloudy_unit&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=$wpcloudy_lang_owm");
    $myweather_sevendays = simplexml_load_file("http://api.openweathermap.org/data/2.5/forecast/daily?q=$wpcloudy_city,$wpcloudy_country_code&mode=xml&units=$wpcloudy_unit&cnt=7&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=$wpcloudy_lang_owm");

    with:

    $path = "http://api.openweathermap.org/data/2.5/forecast?q=$wpcloudy_city,$wpcloudy_country_code&mode=xml&units=$wpcloudy_unit&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=$wpcloudy_lang_owm";
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $path);
      curl_setopt($ch, CURLOPT_FAILONERROR, 1);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_TIMEOUT, 15);
      $returned = curl_exec($ch);
      curl_close($ch);
      $myweather = simplexml_load_string($returned);
    
      $path = "http://api.openweathermap.org/data/2.5/forecast/daily?q=$wpcloudy_city,$wpcloudy_country_code&mode=xml&units=$wpcloudy_unit&cnt=7&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=$wpcloudy_lang_owm";
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $path);
      curl_setopt($ch, CURLOPT_FAILONERROR, 1);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_TIMEOUT, 15);
      $returned = curl_exec($ch);
      curl_close($ch);
      $myweather_sevendays = simplexml_load_string($returned);

    This is tested up to plugin version 2.4 I think but should work fine.

  9. Walter Bishop
    Member
    Posted 6 months ago #

    This is the error I am receiving. Mr Press's code made the errors disappear, but did not make the weather download. I updated to 2.6.2 but it is still broken. Same error, and it puts every temperature at 0.

    Warning: simplexml_load_file(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/escapeto/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1725
    
    Warning: simplexml_load_file(http://api.openweathermap.org/data/2.5/weather?q=Manta,Ecuador&mode=xml&units=metric&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=en): failed to open stream: no suitable wrapper could be found in /home/escapeto/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1725
    
    Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://api.openweathermap.org/data/2.5/weather?q=Manta,Ecuador&mode=xml&units=metric&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=en" in /home/escapeto/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1725
    
    Warning: simplexml_load_file(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/escapeto/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1727
    
    Warning: simplexml_load_file(http://api.openweathermap.org/data/2.5/forecast/weather?q=Manta,Ecuador&mode=xml&units=metric&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=en): failed to open stream: no suitable wrapper could be found in /home/escapeto/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1727
    
    Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://api.openweathermap.org/data/2.5/forecast/weather?q=Manta,Ecuador&mode=xml&units=metric&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=en" in /home/escapeto/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1727
    
    Warning: simplexml_load_file(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/escapeto/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1735
    
    Warning: simplexml_load_file(http://api.openweathermap.org/data/2.5/forecast/daily?q=Manta,Ecuador&mode=xml&units=metric&cnt=7&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=en&cnt=14): failed to open stream: no suitable wrapper could be found in /home/escapeto/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1735
    
    Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://api.openweathermap.org/data/2.5/forecast/daily?q=Manta,Ecuador&mode=xml&units=metric&cnt=7&APPID=46c433f6ba7dd4d29d5718dac3d7f035&lang=en&cnt=14" in /home/escapeto/public_html/wp-content/plugins/wp-cloudy/wpcloudy.php on line 1735
  10. Mr Press
    Member
    Posted 6 months ago #

    @Walter put this line after the code I provided in wpcloudy.php:

    var_dump($myweather);

    Does it show any weather data values when you load a page with your weather shortcode?

  11. rainbowgeek
    Member
    Plugin Author

    Posted 5 months ago #

    If you upgrade to the latest release (v2.6.3), xml errors will now be hidden if Open Weather Map is down.

Reply

You must log in to post.

About this Plugin

About this Topic