nwidart / forecast-php
Forecast.io服务的PHP客户端包
1.0.0
2015-08-02 14:20 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ~5.2
Requires (Dev)
- phpunit/phpunit: ~4.7
- scrutinizer/ocular: ~1.1
This package is auto-updated.
Last update: 2024-09-08 06:52:29 UTC
README
一个用于Forecast.io API的PHP客户端包。
想在Laravel应用中使用?请查看Laravel-Forecast包。
安装
通过Composer
$ composer require nwidart/forecast-php
用法
$forecast = new \Nwidart\ForecastPhp\Forecast('your_api_key'); // Simple latitude and longitude $info = $forecast->get('40.7324296', '-73.9977264'); // Fetch weather at a given time $info = $forecastPhp->get('40.7324296', '-73.9977264', '2013-05-06T12:00:00-0400'); // Add options to the request $info = $forecastPhp->setOptions(['units' => 'si',])->get('40.7324296', '-73.9977264');
更多详细信息及所有可用选项,请查看官方文档。
示例响应
{ "latitude": 40.7324296, "longitude": -73.9977264, "timezone": "America/New_York", "offset": -4, "currently": { "time": 1438445386, "summary": "Partly Cloudy", "icon": "partly-cloudy-day", "nearestStormDistance": 63, "nearestStormBearing": 360, "precipIntensity": 0, "precipProbability": 0, "temperature": 84.71, "apparentTemperature": 85.39, "dewPoint": 62.25, "humidity": 0.47, "windSpeed": 7.95, "visibility": 10, "cloudCover": 0.59, "pressure": 1010.33, "ozone": 323.24 }, "minutely": { ... }, "hourly": { ... }, "daily": { ... }, "flags": { ... }, "headers": { ... } }
测试
$ phpunit
贡献
请查看CONTRIBUTING以获取详细信息。
致谢
许可证
MIT许可证(MIT)。请参阅许可证文件获取更多信息。