sunsgne / weather
weather
0.1.2
2022-05-17 04:08 UTC
Requires
- php: >=7.2
- ext-json: *
- guzzlehttp/guzzle: ^6.5|^7.0
Requires (Dev)
- phpunit/phpunit: ~7.0|~8.0|~9.0
- tinywan/weather: ^0.0.1
- workerman/webman: ^1.0
README
高德地图 weather
🌈 基于IP获取高德开放平台的天气信息插件
安装
composer require sunsgne/weather
使用
配置
高德开放平台 注册账号,然后创建应用,获取应用的 API Key。
地理位置
$clientIp = $request->getRealIp(); sunsgne\Weather::getClientCityByIp($clientIp);
响应
array(7) { ["status"]=> string(1) "1" ["info"]=> string(2) "OK" ["infocode"]=> string(5) "10000" ["province"]=> string(9) "重庆市" ["city"]=> string(9) "重庆市" ["adcode"]=> string(6) "500000" ["rectangle"]=> string(46) "106.2832832,29.36962828;106.8138242,29.7401968" }
实时天气
$clientIp = $request->getRealIp(); sunsgne\Weather::liveWeather($clientIp);
预报天气
$clientIp = $request->getRealIp(); sunsgne\Weather::forecastsWeather($clientIp);