腾讯天气的API接口

请求URL:

  • https://wis.qq.com/weather/common

请求方式:

  • GET

参数:

参数名必选类型说明
sourcestringpc
weather_typestringobserve
provincestring
citystring
countystring

请求示例
https://wis.qq.com/weather/common?source=pc&weather_type=observe|forecast_1h|forecast_24h|index|alarm|limit|tips|rise&province=上海&city=上海&county=浦东新区

返回示例

{
  "data": {
    "alarm": {},
    "forecast_1h": {
      "0": {
        "degree": "17",
        "update_time": "20230510080000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "1": {
        "degree": "19",
        "update_time": "20230510090000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "2": {
        "degree": "21",
        "update_time": "20230510100000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "3": {
        "degree": "22",
        "update_time": "20230510110000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "4": {
        "degree": "22",
        "update_time": "20230510120000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "5": {
        "degree": "22",
        "update_time": "20230510130000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "6": {
        "degree": "22",
        "update_time": "20230510140000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "7": {
        "degree": "21",
        "update_time": "20230510150000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "8": {
        "degree": "21",
        "update_time": "20230510160000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "9": {
        "degree": "20",
        "update_time": "20230510170000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "10": {
        "degree": "19",
        "update_time": "20230510180000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "11": {
        "degree": "17",
        "update_time": "20230510190000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "12": {
        "degree": "16",
        "update_time": "20230510200000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "13": {
        "degree": "16",
        "update_time": "20230510210000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "14": {
        "degree": "15",
        "update_time": "20230510220000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "15": {
        "degree": "15",
        "update_time": "20230510230000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "16": {
        "degree": "14",
        "update_time": "20230511000000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "17": {
        "degree": "14",
        "update_time": "20230511010000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "18": {
        "degree": "13",
        "update_time": "20230511020000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "南风",
        "wind_power": "3"
      },
      "19": {
        "degree": "14",
        "update_time": "20230511030000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "南风",
        "wind_power": "3"
      },
      "20": {
        "degree": "14",
        "update_time": "20230511040000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "南风",
        "wind_power": "3"
      },
      "21": {
        "degree": "14",
        "update_time": "20230511050000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "南风",
        "wind_power": "3"
      },
      "22": {
        "degree": "15",
        "update_time": "20230511060000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "23": {
        "degree": "16",
        "update_time": "20230511070000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "24": {
        "degree": "17",
        "update_time": "20230511080000",
        "weather": "多云",
        "weather_code": "01",
        "weather_short": "多云",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "25": {
        "degree": "19",
        "update_time": "20230511090000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "26": {
        "degree": "20",
        "update_time": "20230511100000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "27": {
        "degree": "21",
        "update_time": "20230511110000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "28": {
        "degree": "22",
        "update_time": "20230511120000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "29": {
        "degree": "22",
        "update_time": "20230511130000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "30": {
        "degree": "22",
        "update_time": "20230511140000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "31": {
        "degree": "22",
        "update_time": "20230511150000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "32": {
        "degree": "21",
        "update_time": "20230511160000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "33": {
        "degree": "21",
        "update_time": "20230511170000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "34": {
        "degree": "20",
        "update_time": "20230511180000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "35": {
        "degree": "19",
        "update_time": "20230511190000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "36": {
        "degree": "18",
        "update_time": "20230511200000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "37": {
        "degree": "18",
        "update_time": "20230511210000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "38": {
        "degree": "18",
        "update_time": "20230511220000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "39": {
        "degree": "17",
        "update_time": "20230511230000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "40": {
        "degree": "17",
        "update_time": "20230512000000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "41": {
        "degree": "16",
        "update_time": "20230512010000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "42": {
        "degree": "15",
        "update_time": "20230512020000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "43": {
        "degree": "15",
        "update_time": "20230512030000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "44": {
        "degree": "15",
        "update_time": "20230512040000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "45": {
        "degree": "15",
        "update_time": "20230512050000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东风",
        "wind_power": "3"
      },
      "46": {
        "degree": "16",
        "update_time": "20230512060000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      },
      "47": {
        "degree": "17",
        "update_time": "20230512070000",
        "weather": "阴",
        "weather_code": "02",
        "weather_short": "阴",
        "wind_direction": "东南风",
        "wind_power": "3"
      }
    },
    "forecast_24h": {
      "0": {
        "day_weather": "雾",
        "day_weather_code": "18",
        "day_weather_short": "雾",
        "day_wind_direction": "东风",
        "day_wind_direction_code": "2",
        "day_wind_power": "3",
        "day_wind_power_code": "0",
        "max_degree": "24",
        "min_degree": "10",
        "night_weather": "阴",
        "night_weather_code": "02",
        "night_weather_short": "阴",
        "night_wind_direction": "东风",
        "night_wind_direction_code": "2",
        "night_wind_power": "3",
        "night_wind_power_code": "0",
        "time": "2023-05-09"
      },
      "1": {
        "day_weather": "多云",
        "day_weather_code": "01",
        "day_weather_short": "多云",
        "day_wind_direction": "东风",
        "day_wind_direction_code": "2",
        "day_wind_power": "3",
        "day_wind_power_code": "0",
        "max_degree": "23",
        "min_degree": "13",
        "night_weather": "阴",
        "night_weather_code": "02",
        "night_weather_short": "阴",
        "night_wind_direction": "东风",
        "night_wind_direction_code": "2",
        "night_wind_power": "3",
        "night_wind_power_code": "0",
        "time": "2023-05-10"
      },
      "2": {
        "day_weather": "阴",
        "day_weather_code": "02",
        "day_weather_short": "阴",
        "day_wind_direction": "东风",
        "day_wind_direction_code": "2",
        "day_wind_power": "3",
        "day_wind_power_code": "0",
        "max_degree": "22",
        "min_degree": "15",
        "night_weather": "阴",
        "night_weather_code": "02",
        "night_weather_short": "阴",
        "night_wind_direction": "东南风",
        "night_wind_direction_code": "3",
        "night_wind_power": "3",
        "night_wind_power_code": "0",
        "time": "2023-05-11"
      },
      "3": {
        "day_weather": "阴",
        "day_weather_code": "02",
        "day_weather_short": "阴",
        "day_wind_direction": "东南风",
        "day_wind_direction_code": "3",
        "day_wind_power": "3",
        "day_wind_power_code": "0",
        "max_degree": "24",
        "min_degree": "13",
        "night_weather": "晴",
        "night_weather_code": "00",
        "night_weather_short": "晴",
        "night_wind_direction": "西南风",
        "night_wind_direction_code": "5",
        "night_wind_power": "3",
        "night_wind_power_code": "0",
        "time": "2023-05-12"
      },
      "4": {
        "day_weather": "多云",
        "day_weather_code": "01",
        "day_weather_short": "多云",
        "day_wind_direction": "东风",
        "day_wind_direction_code": "2",
        "day_wind_power": "3",
        "day_wind_power_code": "0",
        "max_degree": "27",
        "min_degree": "18",
        "night_weather": "多云",
        "night_weather_code": "01",
        "night_weather_short": "多云",
        "night_wind_direction": "东南风",
        "night_wind_direction_code": "3",
        "night_wind_power": "3",
        "night_wind_power_code": "0",
        "time": "2023-05-13"
      },
      "5": {
        "day_weather": "晴",
        "day_weather_code": "00",
        "day_weather_short": "晴",
        "day_wind_direction": "南风",
        "day_wind_direction_code": "4",
        "day_wind_power": "3",
        "day_wind_power_code": "0",
        "max_degree": "30",
        "min_degree": "18",
        "night_weather": "晴",
        "night_weather_code": "00",
        "night_weather_short": "晴",
        "night_wind_direction": "东南风",
        "night_wind_direction_code": "3",
        "night_wind_power": "3",
        "night_wind_power_code": "0",
        "time": "2023-05-14"
      },
      "6": {
        "day_weather": "晴",
        "day_weather_code": "00",
        "day_weather_short": "晴",
        "day_wind_direction": "东南风",
        "day_wind_direction_code": "3",
        "day_wind_power": "3",
        "day_wind_power_code": "0",
        "max_degree": "27",
        "min_degree": "19",
        "night_weather": "晴",
        "night_weather_code": "00",
        "night_weather_short": "晴",
        "night_wind_direction": "东南风",
        "night_wind_direction_code": "3",
        "night_wind_power": "3",
        "night_wind_power_code": "0",
        "time": "2023-05-15"
      },
      "7": {
        "day_weather": "晴",
        "day_weather_code": "00",
        "day_weather_short": "晴",
        "day_wind_direction": "东南风",
        "day_wind_direction_code": "3",
        "day_wind_power": "4",
        "day_wind_power_code": "1",
        "max_degree": "27",
        "min_degree": "18",
        "night_weather": "多云",
        "night_weather_code": "01",
        "night_weather_short": "多云",
        "night_wind_direction": "东南风",
        "night_wind_direction_code": "3",
        "night_wind_power": "4",
        "night_wind_power_code": "1",
        "time": "2023-05-16"
      }
    },
    "index": {
      "airconditioner": {
        "detail": "您将感到很舒适,一般不需要开启空调。",
        "info": "较少开启",
        "name": "空调开启"
      },
      "allergy": {
        "detail": "天气条件较易诱发过敏,宜穿长衣长裤,远离过敏源,适当佩戴眼镜和口罩。",
        "info": "较易发",
        "name": "过敏"
      },
      "carwash": {
        "detail": "适宜洗车,未来持续两天无雨天气较好,适合擦洗汽车,蓝天白云、风和日丽将伴您的车子连日洁净。",
        "info": "适宜",
        "name": "洗车"
      },
      "chill": {
        "detail": "温度未达到风寒所需的低温,稍作防寒准备即可。",
        "info": "无",
        "name": "风寒"
      },
      "clothes": {
        "detail": "建议着薄外套、开衫牛仔衫裤等服装。年老体弱者应适当添加衣物,宜着夹克衫、薄毛衣等。",
        "info": "较舒适",
        "name": "穿衣"
      },
      "cold": {
        "detail": "各项气象条件适宜,无明显降温过程,发生感冒机率较低。",
        "info": "少发",
        "name": "感冒"
      },
      "comfort": {
        "detail": "白天温度适宜,风力不大,相信您在这样的天气条件下,应会感到比较清爽和舒适。",
        "info": "舒适",
        "name": "舒适度"
      },
      "diffusion": {
        "detail": "气象条件对空气污染物稀释、扩散和清除无明显影响。",
        "info": "中",
        "name": "空气污染扩散条件"
      },
      "dry": {
        "detail": "天气较好,路面比较干燥,路况较好。",
        "info": "干燥",
        "name": "路况"
      },
      "drying": {
        "detail": "天气不错,适宜晾晒。赶紧把久未见阳光的衣物搬出来吸收一下太阳的味道吧!",
        "info": "适宜",
        "name": "晾晒"
      },
      "fish": {
        "detail": "较适合垂钓,但风力稍大,会对垂钓产生一定的影响。",
        "info": "较适宜",
        "name": "钓鱼"
      },
      "heatstroke": {
        "detail": "天气不热,在炎炎夏日中十分难得,可以告别暑气漫漫啦~",
        "info": "无中暑风险",
        "name": "中暑"
      },
      "makeup": {
        "detail": "风力不大,建议用中性保湿型霜类化妆品,无需选用防晒化妆品。",
        "info": "保湿",
        "name": "化妆"
      },
      "mood": {
        "detail": "天气较好,温度适宜,心情会不错,学习、工作效率较高。",
        "info": "较好",
        "name": "心情"
      },
      "morning": {
        "detail": "天气不错,空气清新。",
        "info": "适宜",
        "name": "晨练"
      },
      "sports": {
        "detail": "天气较好,赶快投身大自然参与户外运动,尽情感受运动的快乐吧。",
        "info": "适宜",
        "name": "运动"
      },
      "sunglasses": {
        "detail": "白天太阳辐射较强,建议佩戴透射比1级且标注UV380-UV400的浅色太阳镜",
        "info": "必要",
        "name": "太阳镜"
      },
      "sunscreen": {
        "detail": "属中等强度紫外辐射天气,注意防护,建议涂擦SPF指数高于15,PA+的防晒护肤品。",
        "info": "中等",
        "name": "防晒"
      },
      "time": "20230510",
      "tourism": {
        "detail": "天气较好,但丝毫不会影响您出行的心情。温度适宜又有微风相伴,适宜旅游。",
        "info": "适宜",
        "name": "旅游"
      },
      "traffic": {
        "detail": "天气较好,路面干燥,交通气象条件良好,车辆可以正常行驶。",
        "info": "良好",
        "name": "交通"
      },
      "ultraviolet": {
        "detail": "属中等强度紫外线辐射天气,建议涂擦SPF高于15、PA+的防晒护肤品,戴帽子、太阳镜。",
        "info": "中等",
        "name": "紫外线强度"
      },
      "umbrella": {
        "detail": "天气较好,不会降水,因此您可放心出门,无须带雨伞。",
        "info": "不带伞",
        "name": "雨伞"
      }
    },
    "limit": {
      "tail_number": "",
      "time": ""
    },
    "observe": {
      "degree": "19",
      "humidity": "38",
      "precipitation": "0",
      "pressure": "1018",
      "update_time": "202305100850",
      "weather": "多云",
      "weather_code": "01",
      "weather_short": "多云",
      "wind_direction": "2",
      "wind_power": "2"
    },
    "rise": {
      "0": {
        "sunrise": "05:01",
        "sunset": "18:38",
        "time": "20230510"
      },
      "1": {
        "sunrise": "05:01",
        "sunset": "18:39",
        "time": "20230511"
      },
      "2": {
        "sunrise": "05:00",
        "sunset": "18:40",
        "time": "20230512"
      },
      "3": {
        "sunrise": "04:59",
        "sunset": "18:40",
        "time": "20230513"
      },
      "4": {
        "sunrise": "04:58",
        "sunset": "18:41",
        "time": "20230514"
      },
      "5": {
        "sunrise": "04:58",
        "sunset": "18:42",
        "time": "20230515"
      },
      "6": {
        "sunrise": "04:57",
        "sunset": "18:42",
        "time": "20230516"
      },
      "7": {
        "sunrise": "04:57",
        "sunset": "18:43",
        "time": "20230517"
      },
      "8": {
        "sunrise": "04:56",
        "sunset": "18:44",
        "time": "20230518"
      },
      "9": {
        "sunrise": "04:55",
        "sunset": "18:44",
        "time": "20230519"
      },
      "10": {
        "sunrise": "04:55",
        "sunset": "18:45",
        "time": "20230520"
      },
      "11": {
        "sunrise": "04:54",
        "sunset": "18:46",
        "time": "20230521"
      },
      "12": {
        "sunrise": "04:54",
        "sunset": "18:46",
        "time": "20230522"
      },
      "13": {
        "sunrise": "04:53",
        "sunset": "18:47",
        "time": "20230523"
      },
      "14": {
        "sunrise": "04:53",
        "sunset": "18:47",
        "time": "20230524"
      }
    },
    "tips": {
      "observe": {
        "0": "光芒透过云缝,洒向大地~",
        "1": "现在的温度比较凉爽~"
      }
    }
  },
  "message": "OK",
  "status": 200
}

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
首先,需要在腾讯云官网上申请 API 密钥,具体步骤如下: 1. 登录腾讯云控制台,进入 API 密钥管理页面。 2. 点击“新建密钥”按钮,生成 API 密钥。 3. 将密钥保存好,以便在 PHP 代码中调用。 接下来,可以使用 PHP CURL 函数调用腾讯云 API 接口,具体步骤如下: 1. 构造请求 URL,包括接口地址、请求参数、签名等信息; 2. 使用 CURL 函数发送请求,获取服务器响应; 3. 解析服务器响应,提取需要的信息。 下面是一个简单的 PHP 代码示例,演示如何调用腾讯云 API 接口: ``` <?php // 定义 API 地址和请求参数 $url = "https://api.qcloud.com/v2/index.php"; $params = array( "Action" => "DescribeInstances", "Nonce" => rand(), "Region" => "ap-guangzhou", "SecretId" => "your_secret_id", "SignatureMethod" => "HmacSHA256", "Timestamp" => time(), ); // 计算签名 ksort($params); $srcStr = "GET" . $url . "?" . http_build_query($params); $signStr = base64_encode(hash_hmac("sha256", $srcStr, "your_secret_key", true)); $params["Signature"] = $signStr; // 发送请求 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url . "?" . http_build_query($params)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // 解析响应 $result = json_decode($response, true); print_r($result); ?> ``` 在上面的代码中,需要替换以下参数: - your_secret_id:替换为自己的 API 密钥 ID; - your_secret_key:替换为自己的 API 密钥 Key。 此外,还需要根据接口文档,调整请求参数和响应解析方式。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值