api-client-darsky / darksky-client
This package is abandoned and no longer maintained.
No replacement package was suggested.
Dark sky simple api client
dev-master
2018-09-07 12:39 UTC
Requires
- php: ^7.1
- api-clients/client-services: ^1.1
- api-clients/foundation: ^1.0
- api-clients/middleware-json: ^1.0
- api-clients/middleware-user-agent: ^1.0
Requires (Dev)
- api-clients/resource-generator: dev-master
- api-clients/resource-test-utilities: ^1.0
- api-clients/test-utilities: ^4.3
This package is auto-updated.
Last update: 2023-04-14 00:32:35 UTC
README
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.