參數名稱 | 類型 | 必填 | 說明 |
---|---|---|---|
city | string | 否 | 城市 |
cityid | int | 否 | 城市ID |
citycode | string | 否 | 城市天氣代號 |
location | string | 否 | 經緯度 緯度在前,,分割 如:39.983424,116.322987 |
ip | string | 否 | IP |
參數名稱 | 類型 | 說明 |
---|---|---|
city | string | 城市 |
cityid | int | 城市ID |
citycode | string | 城市天氣代號 |
date | string | 日期 |
week | string | 星期 |
weather | string | 天氣 |
temp | string | 氣溫 ℃ |
temphigh | string | 最高氣溫 ℃ |
templow | string | 最低氣溫 ℃ |
img | string | 圖片數字 |
humidity | string | 濕度 % |
pressure | string | 氣壓 hpa |
windspeed | string | 風速 m/s |
winddirect | string | 風向 |
windpower | string | 風級 |
updatetime | string | 更新時間 |
index | string | 生活指數 |
iname | string | 指數名稱 |
ivalue | string | 指數值 |
detail | string | 指數詳情 |
so2 | string | 二氧化硫1小時平均 μg/m3 |
so224 | string | 二氧化硫24小時平均 μg/m3 |
no2 | string | 二氧化氮1小時平均 μg/m3 |
no224 | string | 二氧化氮24小時平均 μg/m3 |
co | string | 一氧化碳1小時平均 mg/m3 |
co24 | string | 一氧化碳24小時平均 mg/m3 |
o3 | string | 臭氧1小時平均 μg/m3 |
o38 | string | 臭氧8小時平均 μg/m3 |
o324 | string | 臭氧24小時平均 μg/m3 |
pm10 | string | PM10 1小時平均 μg/m3 |
pm1024 | string | PM10 24小時平均 μg/m3 |
pm2_5 | string | PM2.5 1小時平均 μg/m3 |
pm2_524 | string | PM2.5 24小時平均 μg/m3 |
iso2 | string | 二氧化硫指數 |
ino2 | string | 二氧化氮指數 |
ico | string | 一氧化碳指數 |
io3 | string | 臭氧指數 |
io38 | string | 臭氧8小時指數 |
ipm10 | string | PM10指數 |
ipm2_5 | string | PM2.5指數 |
aqi | string | AQI指數 |
primarypollutant | string | 首要污染物 |
quality | string | 空氣質量指數類別,有“優、良、輕度污染、中度污染、重度污染、嚴重污染”6類 |
timepoint | string | 發布時間 |
aqiinfo | string | AQI指數信息 |
level | string | 等級 |
color | string | 指數顏色值 |
affect | string | 對健康的影響 |
measure | string | 建議采取的措施 |
daily | string | 按天時間 |
night | string | 夜間 |
sunset | string | 日落時間 |
day | string | 白天 |
hourly | string | 按小時 |
time | string | 時間 |
soncity | string | 城市 有些地級市取市府的天氣 |
soncityid | int | 城市ID |
soncitycode | string | 城市代號 |
sunrise | string | 日出時間 |
<?php require_once 'curl.func.php'; $appkey = 'your_appkey_here';//你的appkey $city = '安順';//utf8 $cityid='111';//任選 $citycode='101260301';//任選 $url = "https://api.jisuapi.com/weather/query?appkey=$appkey&city=$city"; $result = curlOpen($url, ['ssl'=>true]); $jsonarr = json_decode($result, true); //exit(var_dump($jsonarr)); if($jsonarr['status'] != 0) { echo $jsonarr['msg']; exit(); } $result = $jsonarr['result']; echo $result['city'].' '.$result['cityid'].' '.$result['citycode'].' '.$result['date'].' '.$result['week'].' '.$result['weather'].' '.$result['temp'].'
'; echo $result['temphigh'].' '.$result['templow'].' '.$result['img'].' '.$result['humidity'].' '.$result['pressure'].' '.$result['windspeed'].' '.$result['winddirect'].'
'; echo $result['windpower'].' '.$result['updatetime'].'
'; echo '指數:
'; foreach($result['index'] as $index) { echo $index['iname'].' '.$index['ivalue'].' '.$index['detail']. '
'; } echo '空氣質量指數:
'; $aqi = $result['aqi']; echo $aqi['so2'].' '.$aqi['so224'].' '.$aqi['no2'].' '.$aqi['no224'].' '.$aqi['co']. '
'; echo $aqi['co24'].' '.$aqi['o3'].' '.$aqi['o38'].' '.$aqi['o324'].' '.$aqi['pm10']. '
'; echo $aqi['pm1024'].' '.$aqi['pm2_5'].' '.$aqi['pm2_524'].' '.$aqi['iso2'].' '.$aqi['ino2']. '
'; echo $aqi['ico'].' '.$aqi['io3'].' '.$aqi['io38'].' '.$aqi['ipm10'].' '.$aqi['ipm2_5']. '
'; echo $aqi['aqi'].' '.$aqi['primarypollutant'].' '.$aqi['quality'].' '.$aqi['timepoint']. '
'; echo $aqi['aqiinfo']['level'].' '.$aqi['aqiinfo']['color'].' '.$aqi['aqiinfo']['affect'].' '.$aqi['aqiinfo']['measure']. '
'; echo '未來幾天天氣:
'; foreach($result['daily'] as $daily) { echo $daily['date'].' '.$daily['week'].' '.$daily['sunrise'].' '.$daily['sunset']. '
'; echo $daily['night']['weather'].' '.$daily['night']['templow'].' '.$daily['night']['img'].' '.$daily['night']['winddirect'].' '.$daily['night']['windpower']. '
'; echo $daily['day']['weather'].' '.$daily['day']['temphigh'].' '.$daily['day']['img'].' '.$daily['day']['winddirect'].' '.$daily['day']['windpower']. '
'; } echo '未來幾小時天氣:
'; foreach($result['hourly'] as $hourly) { echo $hourly['time'].' '.$hourly['weather'].' '.$hourly['temp'].' '.$hourly['img']. '
'; }
{ "status": 0, "msg": "ok", "result": { "city": "安順", "cityid": "111", "citycode": "101260301", "date": "2015-12-22", "week": "星期二", "weather": "多云", "temp": "16", "temphigh": "18", "templow": "9", "img": "1", "humidity": "55", "pressure": "879", "windspeed": "14.0", "winddirect": "南風", "windpower": "2級", "updatetime": "2015-12-22 15:37:03", "index": [ { "iname": "空調指數", "ivalue": "較少開啟", "detail": "您將感到很舒適,一般不需要開啟空調。" }, { "iname": "運動指數", "ivalue": "較適宜", "detail": "天氣較好,無雨水困擾,較適宜進行各種運動,但因氣溫較低,在戶外運動請注意增減衣物。" } ], "aqi": { "so2": "37", "so224": "43", "no2": "24", "no224": "21", "co": "0.647", "co24": "0.675", "o3": "26", "o38": "14", "o324": "30", "pm10": "30", "pm1024": "35", "pm2_5": "23", "pm2_524": "24", "iso2": "13", "ino2": "13", "ico": "7", "io3": "9", "io38": "7", "ipm10": "35", "ipm2_5": "35", "aqi": "35", "primarypollutant": "PM10", "quality": "優", "timepoint": "2015-12-09 16:00:00", "aqiinfo": { "level": "一級", "color": "#00e400", "affect": "空氣質量令人滿意,基本無空氣污染", "measure": "各類人群可正?;顒? } }, "daily": [ { "date": "2015-12-22", "week": "星期二", "sunrise": "07:39", "sunset": "18:09", "night": { "weather": "多云", "templow": "9", "img": "1", "winddirect": "無持續風向", "windpower": "微風" }, "day": { "weather": "多云", "temphigh": "18", "img": "1", "winddirect": "無持續風向", "windpower": "微風" } } ], "hourly": [ { "time": "16:00", "weather": "多云", "temp": "14", "img": "1" }, { "time": "17:00", "weather": "多云", "temp": "13", "img": "1" } ] } }
代號 | 說明 |
---|---|
201 | 城市和城市ID和城市代號都為空 |
202 | 城市不存在 |
203 | 此城市沒有天氣信息 |
210 | 沒有信息 |
代號 | 說明 |
---|---|
101 | APPKEY為空或不存在 |
102 | APPKEY已過期 |
103 | APPKEY無請求此數據權限 |
104 | 請求超過次數限制 |
105 | IP被禁止 |
106 | IP請求超過限制 |
107 | 接口維護中 |
108 | 接口已停用 |
計次套餐 | 套餐規格 | 價格 | ||
---|---|---|---|---|
免費套餐 | 1000次 | 0.00元 | ≈0元/次 | |
Level3 | 50000次 | 21.00元 | ≈0.00042元/次 | |
Level4 | 100000次 | 40.00元 | ≈0.0004元/次 | |
* 包月套餐和計次套餐不可同時購買,不可疊加使用。 |
包月套餐 | 套餐規格 | 價格 | ||
---|---|---|---|---|
Level2 特惠 | 3000次/天 | 27.00元 | ≈0.00030元/次 | |
Level3 | 6000次/天 | 52.00元 | ≈0.00029元/次 | |
Level4 | 10000次/天 | 84.00元 | ≈0.00028元/次 | |
* 套餐使用時限為訂購之日起30日。 |