Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

jorgik1/darksky-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Darksky

A simple async client for Dark Sky API

Server Requirements

  • PHP >= 7.1

Install

  • Get the API key from https://darksky.net/dev
  • Install this package in your project:
    composer require api-client-darsky/darksky-client

Quickstart example

Once installed, you can use the following code to access a api server and get some weather data:

use ApiClients\Client\DarkSkyClient\AsyncClient;
use React\EventLoop\Factory;
use function ApiClients\Foundation\resource_pretty_print;

require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
$loop = Factory::create();
$latitude = '37.8267';
$longitude = '-122.4233';
$client = AsyncClient::create($loop, require 'resolve_token.php');
$client->fetch( $latitude, $longitude)
  ->done(function (ApiClients\Client\DarkSkyClient\Resource\ResponseInterface $response) {
    resource_pretty_print($response);
  });
$loop->run();

See also the examples.