PHPackages                             leo0315/weather - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. leo0315/weather

ActiveLibrary

leo0315/weather
===============

A weather sdk

0.3.1(4y ago)012MITPHPPHP ^7.2.5 || ^8.0

Since Dec 26Pushed 4y ago1 watchersCompare

[ Source](https://github.com/zhihanglee/weather)[ Packagist](https://packagist.org/packages/leo0315/weather)[ RSS](/packages/leo0315-weather/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (4)Versions (8)Used By (0)

---

Weather
=======

[](#weather)

基于 [高德开放平台](https://lbs.amap.com/dev/id/newuser) 的 PHP 天气信息组件

[![Build Status](https://camo.githubusercontent.com/0a9d44c5726da46e66a4e439a8bcbbb14f627edacffefbc50abc448b18664499/68747470733a2f2f7472617669732d63692e6f72672f7a686968616e676c65652f776561746865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/zhihanglee/weather)[![StyleCI build status](https://camo.githubusercontent.com/a93a72659a3938ba07dbe3dca42650e76d313ae328e2c3c99ee0bbe6a0cd9662/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3332343439393037392f736869656c64)](https://camo.githubusercontent.com/a93a72659a3938ba07dbe3dca42650e76d313ae328e2c3c99ee0bbe6a0cd9662/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3332343439393037392f736869656c64)

需求
--

[](#需求)

php &gt;=7.2.5

安装
--

[](#安装)

```
$ composer require leo0315/weather -vvv
```

前提
--

[](#前提)

在[高德开放平台](https://lbs.amap.com/dev/id/newuser) 注册账号，然后创建应用，获取应用的 API Key。

使用
--

[](#使用)

```
use Leo0315\Weather\Weather;

$key = '获取的key';

$weather = new Weather($key);
```

### 获取实时天气

[](#获取实时天气)

```
$response = $weather->getLiveWeather('深圳');
```

返回：

```
{
    "status": "1",
    "count": "1",
    "info": "OK",
    "infocode": "10000",
    "lives": [
        {
            "province": "山西",
            "city": "山西省",
            "adcode": "140000",
            "weather": "晴",
            "temperature": "4",
            "winddirection": "南",
            "windpower": "
