snowmannunu/weather

1.0.3 2023-07-04 02:13 UTC

This package is auto-updated.

Last update: 2025-07-18 12:44:39 UTC


README

Tests StyleCI Latest Stable Version Total Downloads License

A weather SDK

Installing

$ composer require snowmannunu/weather -vvv

Config

在使用本扩展之前,你需要去 高德开放平台 注册账号,然后创建应用,获取应用的 API Key。

Usage

use SnowmanNunu\Weather\Weather;

$key = 'your key';

$weather = new Weather($key);

获取实时天气

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

获取近期天气预报

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

Used in Laravel

在 Laravel 中使用也是同样的安装方式,配置写在 config/services.php 中:

'weather' => [
   'key' => env('WEATHER_API_KEY'),
],

在 .env 中配置 WEATHER_API_KEY :

WEATHER_API_KEY=your key

TODO

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT