mohsin/awhere-api-client

Unofficial PHP client for aWhere weather API

v1.0.0 2020-09-11 21:11 UTC

This package is auto-updated.

Last update: 2024-05-12 05:29:53 UTC


README

Introduction

This is an API client library for the aWhere weather APIs.

Usage

The first step is setting up an API client and fetching a fresh token:

$client = new aWhere\Client($clientId, $clientSecret);
$token = $client->getToken();

You may cache/save the token and pass it as the 3rd paramter to the client to re-use it (You can use isTokenValid() method to determine usability of the passed token).

Next, you may call the relevant API to fetch the data. In this initial release, I have only added the Forecast Weather by Geolocation API node for now (and only the basic usage without startDate/endDate). I will add more API nodes in upcoming versions of this library.

$client->getWeatherForecastByGeolocation($latitude, $longitude, $options);

$options corresponds to the query string parameters specified in the documentation. For example,

$options = [
  'limit' => 15,
  'blockSize' => 12,
  'conditionsType' => 'basic',
  'useLocalTime' => true
];

Contributing

Feel free to make PRs in case you want to update this library with more API nodes.