ctlynl/weather
最新稳定版本:v2.0
Composer 安装命令:
composer require ctlynl/weather
包简介
高德API获取天气接口
README 文档
README
基于 高德开放平台 的 PHP 天气信息组件。
安装
$ composer require ctlynl/weather:v2.0 -vvv
配置
在使用本扩展之前,你需要去 高德开放平台 注册账号,然后创建应用,获取应用的 API Key
使用
use Overtrue\Weather\Weather; $key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; $weather = new Weather($key);
参数说明
1、$city - 城市名,比如:“深圳”; 3、$format - 输出的数据格式,默认为 json 格式,当 output 设置为 “xml” 时,输出的为 XML 格式的数据。
获取实时天气
$response = $weather->getLiveWeather('深圳');
获取近期天气预报
$response = $weather->getForecastsWeather('深圳');
获取 XML 格式返回值(默认json)
$response = $weather->getLiveWeather('深圳', 'xml');
LICENSE MIT
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-20