城市天气查询

HTTPS + CDN

稳定、快速、免费的 API 接口服务

接口地址:https://api.wpbom.com/api/weather.php?city=
返回格式:json
请求方式:get/post
请求示例:https://api.wpbom.com/api/weather.php?city=郑州

请求参数说明:

名称 必填 类型 说明
  city string 城市或县区名称,如:郑州市,金水区

返回参数说明:

名称 类型 说明
  data string 返回的日期!
  type string 返回的天气信息!

返回示例:

{"data":{"yesterday":{"date":"30日星期三","high":"高温 4℃","fx":"西南风","low":"低温 -1℃","fl":"","type":"雨夹雪"},"city":"西安","forecast":[{"date":"31日星期四","high":"高温 7℃","fengli":"","low":"低温 -6℃","fengxiang":"西南风","type":"小雪"},{"date":"1日星期五","high":"高温 7℃","fengli":"","low":"低温 -4℃","fengxiang":"东北风","type":"多云"},{"date":"2日星期六","high":"高温 7℃","fengli":"","low":"低温 -3℃","fengxiang":"西南风","type":"多云"},{"date":"3日星期天","high":"高温 10℃","fengli":"","low":"低温 -1℃","fengxiang":"南风","type":"多云"},{"date":"4日星期一","high":"高温 8℃","fengli":"","low":"低温 -3℃","fengxiang":"东北风","type":"多云"}],"ganmao":"昼夜温差很大,易发生感冒,请注意适当增减衣服,加强自我防护避免感冒。","wendu":"2"},"status":1000,"desc":"OK"}

系统级错误码参照:

  错误码 说明 旧版本(resultcode)
  10001 错误的请求KEY 101
  10002 该KEY无请求权限 102
  10003 KEY过期 103
  10004 错误的OPENID 104
  10005 应用未审核超时,请提交认证 105
  10007 未知的请求源 107
  10008 被禁止的IP 108
  10009 被禁止的KEY 109
  10011 当前IP请求超过限制 111
  10012 请求超过次数限制 112
  10013 测试KEY超过请求限制 113
  10014 系统内部异常(调用充值类业务时,请务必联系客服或通过订单查询接口检测订单,避免造成损失) 114
  10020 接口异常 120
  10021 接口停用 121

错误码格式说明(示例:200201):

  2 002 01
  服务级错误(1为系统级错误) 服务模块代码(即数据ID) 具体错误代码

PHP演示:

<?php
$city = $_GET['city'];
$result = file_get_contents("https://api.wpbom.com/api/weather.php?city=".$city);
header("Content-Type:text/html;charset=UTF-8");
print_r($result);
if ($arr['code']==1) {
}
?>
渝ICP备2022001202号