endroid/openweathermap

此包已被废弃,不再维护。未建议替代包。

Endroid OpenWeatherMap

1.1.1 2017-01-01 15:09 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:26:49 UTC


README

endroid提供

Latest Stable Version Build Status Total Downloads Monthly Downloads License

OpenWeatherMap帮助您调用OpenWeatherMap API,无需过多关注传递API密钥和构建请求。您只需要API密钥(APPID),您可以在网站注册后找到它:网站注册

有关官方API文档中自定义参数的更多信息:http://bugs.openweathermap.org/projects/api/wiki/Api_2_5

use Endroid\OpenWeatherMap\Client;

$apiKey = '...';
$client = new Client($apiKey);

// Retrieve the current weather for Breda
$weather = $client->getWeather('Breda,nl');

// Or retrieve the weather using the generic query method
$response = $client->query('weather', ['q' => 'Breda,nl']);
$weather = json_decode($response->getContent());

// You can also retrieve a N days forecast
$forecast = $client->getForecast('Breda,nl', 7);

Symfony集成

在内核中注册Symfony包。

// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new Endroid\OpenWeatherMap\Bundle\EndroidOpenWeatherMapBundle(),
    ];
}

默认参数可以通过配置进行覆盖。

endroid_open_weather_map:
    api_key: '...'
    units: 'metric'

现在您可以按以下方式检索客户端。

$client = $this->get('endroid.open_weather_map.client');

版本管理

版本号遵循MAJOR.MINOR.PATCH方案。向后兼容性破坏性更改将保持在最小,但请注意,这些更改可能会发生。在生产中锁定依赖项,并在升级时测试您的代码。

许可证

此包受MIT许可证的约束。有关完整的版权和许可证信息,请参阅与源代码一起分发的LICENSE文件。