World Weather Online API Wrapper

World Weather Online API Wrapper

Released 5 years ago , Last update 5 years ago

Access current weather conditions and the next 5 days of accurate and reliable weather forecast through the WorldWeatherOnline API

This is an API wrapper for worldweatheronline.com which provides access to meteorological and weather data.

The returned data contains elements such as:

  • Temperature
  • Precipitation (rainfall)
  • Weather description
  • Weather icon
  • Wind speed

Features

  • Simple access to meteorological and weather data
  • Data is cached for 1 hour
  • No adverts

To use the API you need to sign up for API access on WorldWeatherOnline (Registration is free).

5.0
  • 5 1
  • 4 0
  • 3 0
  • 2 0
  • 1 0
1 Reviews Read Reviews

Pricing

14 day 14-day money-back guarantee

FREE

MIT license

The MIT license is an open-source license.

Documentation

<?php
// The Weather class
require_once 'WeatherForecast.class.php';

// Defines the API key provided to register his candidacy
$weather = new WeatherForecast('YOUR_API_KEY');

// Defines the name of the city, the country and the number of days of forecast (between 1 and 5)
$weather->setRequest('New York', 'United States Of America', 3);

// Defines the US unit of measurement
$weather->setUSMetric(true);

// Defines the display of the error message on failure
//$weather->setDisplayError(false);    
?>
<html> 
    <head>
    <title>Weather Forecast</title>
    <link rel="stylesheet" href="screen.css" media="screen" />
    </head>
    <body>
        <?php
        // API call
        $response = $weather->getLocalWeather();

        if ($weather::$has_response) {
            ?>

            <h1><?php echo $response->locality; ?></h1>

            <h2>The Weather Today at <?php echo $response->weather_now['weatherTime']; ?></h2>

            <div class="weather_now">
                <span style="float:right;"><img src="<?php echo $response->weather_now['weatherIcon']; ?>" /></span>
                <strong>DESCRIPTION:</strong> <?php echo $response->weather_now['weatherDesc']; ?><br />
                <strong>TEMPERATURE:</strong> <?php echo $response->weather_now['weatherTemp']; ?><br />
                <strong>WIND SPEED:</strong> <?php echo $response->weather_now['windSpeed']; ?><br />
                <strong>PRECIPITATION:</strong> <?php echo $response->weather_now['precipitation']; ?><br />
                <strong>HUMIDITY:</strong> <?php echo $response->weather_now['humidity']; ?><br />
                <strong>VISIBILITY:</strong> <?php echo $response->weather_now['visibility']; ?><br />
                <strong>PRESSURE:</strong> <?php echo $response->weather_now['pressure']; ?><br />
                <strong>CLOUD COVER:</strong> <?php echo $response->weather_now['cloudcover']; ?><br />
            </div>

            <h3>Weather Forecast</h3>

            <?php
            foreach ($response->weather_forecast as $weather) {
                ?>
                <div class="weather_forecast">
                    <div class="block block1">
                        <span class="icon"><img src="<?php echo $weather['weatherIcon']; ?>" /></span>
                    </div>
                    <div class="block block2">
                        <span class="wday"><?php echo $weather['weatherDay']; ?></span>
                        <span class="date"><?php echo $weather['weatherDate']; ?> </span>
                        <span class="desc"><?php echo $weather['weatherDesc']; ?></span>
                        <span class="wind">Wind: <?php echo $weather['windDirection']; ?> at <?php echo $weather['windSpeed']; ?></span>
                    </div>
                    <div class="block block3">
                        <span class="tmax"><?php echo $weather['tempMax']; ?></span>
                        <span class="tmin"><?php echo $weather['tempMin']; ?></span>
                    </div>
                </div>
                <?php
            }
            ?>

        <?php } ?>
    </body>
</html>
License » MIT license Download

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.


Or enter your name and Email
  • SK Shivanjali Khare 1 month ago
    even i am getting the same error.. how did you resolve it?
  • W web 1 year ago
    i get error "The weather conditions were not found."
    • H hau 9 months ago
      Me too, how did you solve it?
  • P pratik1995 2 years ago
    how to get the weather API key