Google天气API详解
探索Google天气API如何以XML格式提供广泛城市的实时气象信息,支持UTF-8与EUC-KR编码。
上述URL为Google天气API的访问地址。典型的Google产品,它比一般的门户网站支持更多的城市,返回的数据编码格式为EUC-KR(CP949),而非UTF-8,并采用XML格式。
支持的城市
以下列出了API支持的一些城市,可能还有更多:
$googleWeatherCity['kor'] = array("강릉", "경주", "고양", "광명", "광주", "구미", "군산", "군포", "김해", "대구", "대전", "동해", "목포", "부산", "부천", "서귀포", "서울", "성남", "송탄", "수원", "시흥", "안산", "안양", "용인", "울릉도", "울산", "원주", "의정부", "익산", "인천", "일산", "전주", "제주", "진주", "철원", "청주", "춘천", "파주", "평택", "포항", "흑산도", "충주", "상주", "창원", "천안", "여수", "안동", "양산", "태안", "진해", "오산", "순천", "당진", "마산", "삼척", "거제");
$googleWeatherCity['eng'] = array("gangneung", "gyeongju", "goyang", "gwangmyeong", "gwangju", "gumi", "gunsan", "gunpo", "gimhae", "daegu", "daejeon", "donghae", "mokpo", "busan", "bucheon", "seogwipo", "seoul", "seongnam", "songtan", "suwon", "siheung", "ansan", "anyang", "yongin", "ulleung-do", "ulsan", "wonju", "uijeongbu", "iksan", "incheon", "ilsan", "jeonju", "jeju", "jinju", "cheorwon", "cheongju", "chuncheon", "paju", "pyeongtaek", "pohang", "heuksan-do", "chungju", "sangju", "changwon", "cheonan", "yeosu", "andong", "yangsan", "taean", "jinhae", "osan", "suncheon", "dangjin", "masan", "samchok", "kuje");
属性说明
[xml_api_reply][weather][problem_cause] 错误发生时,problem_cause的data属性会显示错误内容。
[xml_api_reply][weather][forecast_information][postal_code] 这是城市名称。请求的城市名称会显示出来,若需要详细城市名,可以读取city属性。
[xml_api_reply][weather][forecast_information][current_date_time] 最近更新的日期。基准为GMT+0。
[xml_api_reply][weather][current_conditions][condition] 当前的天气状况,如晴朗、下雨等以中文显示。
[xml_api_reply][weather][current_conditions][temp_c] 当前温度,以℃显示。
[xml_api_reply][weather][current_conditions][humidity] 当前湿度,以湿度:%的格式显示。
[xml_api_reply][weather][current_conditions][wind_condition] 当前风情况,以风:风暴、8 km/h的格式显示。
[xml_api_reply][weather][forecast_conditions][$i][day_of_week] 未来$i天的天气信息(包括今天,最多4天),显示星期。
[xml_api_reply][weather][forecast_conditions][$i][low] 最低气温。
[xml_api_reply][weather][forecast_conditions][$i][high] 最高气温。
[xml_api_reply][weather][forecast_conditions][$i][condition] 天气状况以中文显示。
更多相关内容
DGX Spark 评测:本地 LLM 比 API 更便宜吗?回本周期计算
大多数情况下,直接调用云端 API 比购买 DGX Spark 部署本地 LLM 更便宜。按回本周期计算:对比 GPT-6 Luna 需约 21 个月才能回本,对比 DeepSeek V4 Flash 则需要约 9 年。
Laravel开发者福音:AI驱动的智能翻译工具,让多语言开发不再头疼!
介绍一款基于AI的Laravel翻译工具,能够快速高效地完成多语言翻译任务,告别繁琐的手动翻译过程。
如何使用JavaScript实现“几小时前”、“几分钟前”、“几秒钟前”的实时时间显示
如何以“几小时前”、“几分钟前”、“几秒钟前”的格式使用JavaScript实现实时时间显示。