fsa/openweathermap-api

OpenWeatherMap.org API

v0.2.0 2022-04-23 18:33 UTC

This package is auto-updated.

Last update: 2024-09-23 23:32:36 UTC


README

该库可用于与 OpenWeather API 交互 - https://api.openweathermap.org。可以通过它们解码消息并将其转换为 PHP 对象。

创建对象时,需要传递字符串 - API 密钥。

用于设置请求参数的方法

  • setCityName($name) - 指定城市名称;
  • setCityId($id) - 指定城市数字标识符;
  • setCoords($lat, $lon) - 指定地理坐标;
  • setZip($zip) - 指定邮政编码;
  • setLang($lang) - 指定语言(默认为 "ru")。

用于获取当前天气信息的方法

  • fetchCurrent() - 返回 JSON 解码后的响应(普通的 json_decode());
  • fetchCurrentEntity() - 返回带有实体类(Entity)的 JSON 解码后的响应;

用于获取天气预报的方法

  • fetchForecast() - 返回 JSON 解码后的响应(普通的 json_decode());
  • fetchForecastEntity() - 返回带有实体类(Entity)的 JSON 解码后的响应;