Skip to content

Releases: leonardfischer/open-weather-map-api

Rewrite API to introduce more flexibility

13 Mar 12:50
Compare
Choose a tag to compare

With this major update the API introduces multiple new dedicated endpoints (according to the data collections of openWeatherMap).

BC Breaks

All previous API calls need to be rewritten in order to make use of the desired "endpoint". As a small example: instead of writing this code (in version 0.1 or 0.2)

use lfischer\openWeatherMap\API;

$weather = (new API('<API-key here>'))->getByCityName('Dusseldorf', 'de');

You will have to use the "current weather" endpoint. The code should look like this instead:

use lfischer\openWeatherMap\API;

$weather = (new API('<API-key here>'))->getCurrentWeather()->byCityName('Dusseldorf,Germany');

New features

More precise endpoints

The goal is to create a PHP class endpoint for each data collection area of the OpenWeatherMap API. Every endpoint class introduces its own methods to set endpoint-specific options.

Better validation

Thanks to typed properties and some Helper classes the API does a lot more validation and handles passed parameters more strictly in order to guarantee correct results.

Request adapters

You can choose from one of four request adapters:

  • cURL
  • Dump (used for unit tests and to simply return the request URL if you'd like to use your own library)
  • Guzzle
  • Simple (uses file_get_contents as previous versions) default

Return types

According to the set mode you will receive one of these three response classes:

  • HtmlResponse
  • JsonResponse default
  • XmlResponse

Update due to API changes

08 Mar 09:51
Compare
Choose a tag to compare

It seems as if the open-weather-map API changed it's response a little so I had to change the API client to process this correctly.

I also added some small new convenience methods and constants

First working release

01 Feb 19:55
Compare
Choose a tag to compare

The first release of the Open Weather Map API client gives you some simple methods to get weather data. The most simple setup looks like this:

// By default the current conditions will be requested in english language.
$weather = (new \lfischer\openWeatherMap\API('<API-key here>'))->getByCityName('Dusseldorf', 'de');

There are a few default settings, you might want to check out (see the README)