sablesoft/api-openweather
Composer 安装命令:
composer require sablesoft/api-openweather
包简介
A php service for Open Weather API
README 文档
README
PHP Service for the Open Weather API
Installation
Using composer:
"require": {
"sablesoft/api-openweather": "*"
}
Via CLI:
composer require sablesoft/api-openweather
Configuration
Required configurations:
- The appId must be set in your application. (Please see here to get one)
Custom configurations:
- the Base URL and Default Guzzle Options. (Please see here for possible options)
Usage
See below for sample initialization code:
<?php
include_once 'vendor/autoload.php';
use SableSoft\OpenWeather\Service;
$appId = 'your_appid_here';
$options = [
'endpount' => 'http://api.openweathermap.org' // already set as default
'timeout' => 3, // default
'connect_timeout' => 3 // default
];
$service = Service::getInstance($appId, $baseUrl, $options);
// get weather forecast by city:
$response = $service->getByCity('Minsk');
if ($response->isValid()) {
print_r($response->getData());
}
// get weather forecast by coordinates:
$response = $service->get(53.9006, 27.5590);
if ($response->isValid()) {
print_r($response->getData());
}
?>
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-22