mbajda / yahoo-weather
Yahoo Weather API PHP 实现
1.1.3
2018-05-05 11:29 UTC
Requires
- php: >=7.1.0
This package is not auto-updated.
Last update: 2024-09-20 22:48:24 UTC
README
此库是 Yahoo Weather API 的 PHP 实现。它允许查询世界上指定地点的多种天气条件。
用法
首先,您需要创建天气 API 端点的实例。为此,只需使用以下代码即可
$cache = new \YahooWeather\Endpoint\Cache\FileCache('var\cache', 60*60*12); $endpoint = new \YahooWeather\Endpoint($cache);
YahooWeather\Endpoint
是库的主要类。
YahooWeather\Endpoint\Cache\FileCache
是与端点一起使用的缓存类。构造函数接受最多 2 个参数。第一个是缓存存储的目录。第二个是缓存存活时间 - 缓存文件将使用的时间。
$endpoint->getWOEIDs('Warsaw');
此行将允许您获取指定位置的 WOEID(位置 ID)。
$endpoint->getData(523920);
getData
方法允许您获取指定 WOEID(这是该方法和其它方法的参数)的所有数据。
附加信息
该库利用与 https://query.yahooapis.com - Yahoo APIs 的连接。每天查询次数有限,等于 2000。