naughtonium/laravel-dark-sky
最新稳定版本:1.2.5
Composer 安装命令:
composer require naughtonium/laravel-dark-sky
包简介
Provides a Wrapper for the DarkSky API
README 文档
README
This provides a Laravel style wrapper for the DarkSky api. For more information regarding request and response formats, visit: https://darksky.net/dev/docs
Install
Require this package with composer using the following command:
$ composer require naughtonium/laravel-dark-sky
After updating composer, add the service provider to the providers array in config/app.php
Naughtonium\LaravelDarkSky\LaravelDarkSkyServiceProvider::class,
To register a facade accessor, add the following to config/app.php aliases array
'DarkSky' => \Naughtonium\LaravelDarkSky\Facades\DarkSky::class,
Configuration
Add the following line to the .env file:
DARKSKY_API_KEY=<your_darksky_api_key>
Usage
For full details of response formats, visit: https://darksky.net/dev/docs/response
Required
location(lat, lon)
Pass in latitude and longitude coordinates for a basic response
DarkSky::location(lat, lon)->get();
Optional Parameters
For full details of optional parameters, visit: https://darksky.net/dev/docs/forecast
excludes([]) / includes([])
Specify which data blocks to exclude/include to reduce data transfer
DarkSky::location(lat, lon)->excludes(['minutely','hourly', 'daily', 'alerts', 'flags'])->get(); DarkSky::location(lat, lon)->includes(['currently'])->get(); // Same output
atTime(t)
Pass in a unix timestamp to get forecast for that time. Note: the timezone is relative to the given location
DarkSky::location(lat, lon)->atTime(timestamp)->get();
language(l)
Specify a language for text based responses
DarkSky::location(lat, lon)->language(lang)->get();
units(u)
Specify units for unit based responses
DarkSky::location(lat, lon)->units(units)->get();
extend()
Extend the "hourly" response from 48 to 168 hours. Note: Does not work if used with an atTime() timestamp. Please see: https://darksky.net/dev/docs/time-machine
DarkSky::location(lat, lon)->extend()->get();
Helpers
The following are shorthand helpers to add readability equal to using includes() with only one parameter. Note: only one may be used per query and only temperature specific data is returned
->currently() ->minutely() ->hourly() ->daily() ->flags()
For example, these two statements are the same
DarkSky::location(lat, lon)->hourly() DarkSky::location(lat, lon)->includes(['hourly'])->get()->hourly
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 55.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-13