owenandrews/willyweather-php
Composer 安装命令:
composer require owenandrews/willyweather-php
包简介
A PHP client for WillyWeathers's v2 API.
关键字:
README 文档
README
A PHP client for WillyWeathers's v2 API. http://www.willyweather.com.au/info/api.html
Note: This is not an official library, nor is it fully featured.
Requirments
- PHP 7 or newer
- A WillyWeather API key
Installation
composer require owenandrews/willyweather-php
Usage
Get a location
Retrieve basic information for a given location ID.
use WillyWeather\Client; $willyWeather = new Client('<API-KEY>'); $sydney = $willyWeather->location(4950); $sydney->getName();
Get forecast and observational data
Retrieve a location's basic forecast and observational data.
use WillyWeather\Client; $willyWeather = new Client('<API-KEY>'); $sydney = $willyWeather->location(4950); $sydney->getForecasts(); $sydney->getObservational();
Get custom forecast data
By default, only the basic 7 day weather forecast is returned. To override this, just add an array of forecast types to the function call. Check out the API documentation for all available forecast types. Keep in mind you must enable each forecast type for your API key, otherwise the request will fail.
use WillyWeather\Client; $willyWeather = new Client('<API-KEY>'); $sydney = $willyWeather->location(4950); $sydney->getForecasts(["forecasts" => ["temperature", "wind", "rainfallprobability"], "days" => 3]);
Shorthand
So far we've recieved location, forecast and observational data, each time making a seperate API request. Thankfully, we can bundle that up into one API call.
use WillyWeather\Client; $willyWeather = new Client('<API-KEY>'); $sydney = $willyWeather->location(4950, ["forecasts" => ["temperature", "wind", "rainfallprobability"], "days" => 3, "observational" => true]); $sydney->getForecasts(); $sydney->getObservational();
This time only one API call was made.
Search
Search for locations based on placename or postcode.
use WillyWeather\Client; $willyWeather = new Client('<API-KEY>'); $sydney = $willyWeather->searchByQuery("Sydney")[0];
Search for locations based on proximity to a set of coordinates.
use WillyWeather\Client; $willyWeather = new Client('<API-KEY>'); $mackenziesBay = $willyWeather->searchByCoordinates(["lat" => -33.8996141, "lng" => 151.272962])[0];
Caching
A basic file-based cache is included, this can help reduce repetitive API calls. To enable it, just pass in a suitable path while constructing the client.
use WillyWeather\Client; $willyWeather = new Client('<API-KEY>', '/tmp/');
Dates and Times
All date/time strings are converted to Carbon objects in the locations local timezone.
Contributing
Contributions are most welcome, just submit a pull request. 😄
License
This project is licensed under the MIT License - see the LICENSE file for details.
Built With
- Guzzle - HTTP client
- GuzzleCache - Guzzle caching middleware
- Carbon - Date time library
- Flysystem - Filesystem abstraction
Authors
owenandrews/willyweather-php 适用场景与选型建议
owenandrews/willyweather-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 05 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「weather」 「willyweather」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 owenandrews/willyweather-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 owenandrews/willyweather-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 owenandrews/willyweather-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel-forecast provides a service provider and a facade around the Forecast-php wrapper
Add a weather widget to Flarum
Simple weather forecaster for Laravel
Unofficial PHP client for aWhere weather API
Anax weather module
An extremely simple PHP Weather Underground API wrapper
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-05-22