Skip to content
tanaka51-jp edited this page May 12, 2012 · 2 revisions

GoogleWeatherAPIについて

概要

  • 現時点(current_conditions)に加え、今日を含めて最大4日分の天気予報(forecast_conditions)が入っている

  • 現時点は、気温や湿度、温度、風の強さが入ってくる

  • 天気予報は、降水確率や風向きなどはなく、天気と最高・最低気温のみ(日本語宣言しない場合、気温は摂氏ではなく、華氏なので注意)

  • 天気予報に含まれる「曜日」は日本時間となっている

  • 30分毎に更新されている

  • XML形式なのだが、データ部が属性となっており、ちょっと使いにくい

  • 天気の画像データも「 http://www.google.com 」にiconの内容を連結させると簡単に取得

  • 若干日本語が不自然

API使用例

  • 以下、全ての URL リクエストは GET とする

都市, 国 (例:”london,england”)

北海道旭川市  
http://www.google.com/ig/api?weather=asahikawa,hokkaido
市町村と都道府県名を指定「weather=」の後ろにカンマ区切りで指定する  

日本語化

http://www.google.com/ig/api?weather=asahikawa,hokkaido&hl=ja
「hl=ja」をつけてあげると天気部分などが日本語で返却される  

座標 (緯度:latitude / 経度:longitude)

緯度/経度による検索も可能です。(緯度/経度は 10 の 6 乗した整数値に変換)
緯度/経度による検索例 (福岡:緯度=33.35 経度=130.24 の場合)
http://www.google.com/ig/api?weather=,,,33350000,130240000

XML構造

This XML file does not appear to have any style information associated with it. The document tree is shown below. < xml_api_reply version="1">
< weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">
< forecast_information>
< city data=""/>
< postal_code data=""/>
< latitude_e6 data="33350000"/>
< longitude_e6 data="130240000"/>
< forecast_date data="2012-04-23"/>
< current_date_time data="1970-01-01 00:00:00 +0000"/>
< unit_system data="SI"/>
< /forecast_information>
< current_conditions>
< condition data="晴れ"/>
< temp_f data="70"/>
< temp_c data="21"/>
< humidity data="湿度 : 56%"/>
< icon data="/ig/images/weather/jp_sunny.gif"/>
< wind_condition data="風: 北西 4 m/s"/>
< /current_conditions>
< forecast_conditions>
< day_of_week data="月"/>
< low data="11"/>
< high data="23"/>
< icon data="/ig/images/weather/jp_sunny.gif"/>
< condition data="晴れ"/>
< /forecast_conditions>
< forecast_conditions>
< day_of_week data="火"/>
< low data="15"/>
< high data="26"/>
< icon data="/ig/images/weather/jp_sunny.gif"/>
< condition data="晴れ"/>
< /forecast_conditions>
< forecast_conditions>
< day_of_week data="水"/>
< low data="14"/>
< high data="24"/>
< icon data="/ig/images/weather/jp_sunny.gif"/>
< condition data="ところにより晴れ"/>
< /forecast_conditions>
< forecast_conditions>
< day_of_week data="木"/>
< low data="12"/>
< high data="21"/>
< icon data="/ig/images/weather/jp_sunny.gif"/>
< condition data="大体晴れ"/>
< /forecast_conditions>
< /weather>
< /xml_api_reply>

参考

http://billboardtop100.net/2011/04/google-weather-api-php.html

http://rtaki.blogspot.jp/2010/11/api.html

Clone this wiki locally