jiminald/dark-sky-api

This package is abandoned and no longer maintained. No replacement package was suggested.

Fetch Dark Sky weather data via their API

v1.0 2019-05-10 22:35 UTC

This package is auto-updated.

Last update: 2020-08-28 15:43:28 UTC


README

Grab weather forecast information using Dark Sky's API

You will need

Installation

You can install this using Composer

{
    "require": {
        "DarkSkyApi": "dev-master"
    }
}

Adapters

By default, the class uses Guzzle to fetch data from the Dark Sky API servers. You can change this to use PHP's file_get_contents, by adding "FGC" to the construct

<?php
$dark_sky = new \DarkSkyApi\DarkSkyApi('API KEY', 'FGC');

While Developing

The code is shipped with some test data use for automated tests, which is useful to use while developing, saving your API allowance. Change your adapter to "Test", to use the sample data.

Example

<?php
require_once __DIR__.'/../vendor/autoload.php';

$dark_sky = new \DarkSkyApi\DarkSkyApi('API KEY');
$forecast = $dark_sky->get_forecast('LATITUDE', 'LONGITUDE');

var_dump($forecast->getHourly());

Inspiration

This class is loosely based on https://github.com/jaimz22/Overcast

I found that Dark Sky had changed their API since Overcast was last updated, and I wanted to make it an easier experience in case they changed their format again.