2008年4月9日水曜日

Google Calendar API で日本の祝日データを取得

Google Calendarから日本の祝日データを取得する方法についての調査メモ。



ポイント

  • GDataを使う場合はデベロッパーKEYが必要だが、GDataを使わなくても日本の祝日カレンダーは取得できる。
  • 祝日名と日付を取得したい場合、Projection valueは"full-noattendees"で。(fullより少しだけデータが小さくなる。)
  • 利用規約はGoogleカレンダー利用規約。



日本の祝日カレンダーのID
  • japanese__ja@holiday.calendar.google.com (Googleカレンダーの公式版)
  • japanese@holiday.calendar.google.com (Googleカレンダーのもう1つのID)
  • outid3el0qkcrsuf89fltf7a4qbacgt9@import.calendar.google.com (mozilla.org版)
    • mozilla.orgにあるカレンダーをインポートしたもの
    • 下記の休日に対応していて、最も精度が高い
      • 2008/5/6の振替休日
      • 2009/5/6の振替休日
      • 2012/3/20の春分の日 (Google公式版では3/21になっている)



URLサンプル
http://www.google.com/calendar/feeds/japanese@holiday.calendar.google.com/public/full-noattendees?start-min=2008-01-01&start-max=2008-01-31&max-results=10&alt=json-in-script&callback=callbackHoliday



取得データサンプル
callbackHoliday({
"version":"1.0",
"encoding":"UTF-8",
"feed":{
"xmlns":"http://www.w3.org/2005/Atom",
"xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/",
"xmlns$batch":"http://schemas.google.com/gdata/batch",
"xmlns$gCal":"http://schemas.google.com/gCal/2005",
"xmlns$gd":"http://schemas.google.com/g/2005",
"id":{"$t":"http://www.google.com/calendar/feeds/japanese%40holiday.calendar.google.com/public/full-noattendees"},
"updated":{"$t":"2008-02-13T10:01:04.000Z"},
"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],
"title":{"type":"text","$t":"Japanese Holidays"},
"subtitle":{"type":"text","$t":"Japanese Holidays"},
"link":[
{
"rel":"alternate",
"type":"text/html",
"href":"http://www.google.com/calendar/embed?srcu003djapanese@holiday.calendar.google.com"
},
{
"rel":"http://schemas.google.com/g/2005#feed",
"type":"application/atom+xml",
"href":"http://www.google.com/calendar/feeds/japanese%40holiday.calendar.google.com/public/full-noattendees"
},
{
"rel":"http://schemas.google.com/g/2005#batch",
"type":"application/atom+xml",
"href":"http://www.google.com/calendar/feeds/japanese..."
},
{
"rel":"self",
"type":"application/atom+xml",
"href":"http://www.google.com/calendar/feeds/japanese..."
}
],
"author":[{"name":{"$t":"Holiday Calendars"},"email":{"$t":"doozer.holiday.calendars@gmail.com"}}],
"generator":{"version":"1.0","uri":"http://www.google.com/calendar","$t":"Google Calendar"},
"openSearch$totalResults":{"$t":"2"},
"openSearch$startIndex":{"$t":"1"},
"openSearch$itemsPerPage":{"$t":"10"},
"gCal$timezone":{"value":"Etc/GMT"},

"entry":[
{
"id":{"$t":"http://www.google.com/calendar/feeds/japanese..."},
"published":{"$t":"2006-09-06T04:52:22.000Z"},
"updated":{"$t":"2006-09-14T08:16:28.000Z"},
"category":[{
"scheme":"http://schemas.google.com/g/2005#kind",
"term":"http://schemas.google.com/g/2005#event"
}],
"title":{"type":"text","$t":"成人の日"},
"content":{"type":"text","$t":""},
"link":[
{
"rel":"alternate",
"type":"text/html",
"href":"http://www.google.com/calendar/event?...",
"title":"alternate"
},
{
"rel":"self",
"type":"application/atom+xml",
"href":"http://www.google.com/calendar/feeds/japanese..."
}
],
"author":[{"name":{"$t":"Japanese Holidays"}}],
"gd$recurrence":{"$t":"DTSTART..."},
"gd$eventStatus":{"value":"http://schemas.google.com/g/2005#event.confirmed"},
"gd$transparency":{"value":"http://schemas.google.com/g/2005#event.opaque"},
"gCal$uid":{"value":"24cihigm..."},
"gCal$sequence":{"value":"0"},
"gd$when":[{"startTime":"2008-01-14","endTime":"2008-01-15"}],
"gd$where":[{"valueString":""}]
},
{
"id":{"$t":"http://www.google.com/calendar/feeds/japanese..."},
"published":{"$t":"2006-09-06T04:52:22.000Z"},
"updated":{"$t":"2006-09-14T08:16:28.000Z"},
"category":[{
"scheme":"http://schemas.google.com/g/2005#kind",
"term":"http://schemas.google.com/g/2005#event"
}],
"title":{"type":"text","$t":"元日"},
"content":{"type":"text","$t":""},
"link":[
{
"rel":"alternate",
"type":"text/html",
"href":"http://www.google.com/calendar/event?...",
"title":"alternate"
},
{
"rel":"self",
"type":"application/atom+xml",
"href":"http://www.google.com/calendar/feeds/japanese..."
}
],
"author":[{"name":{"$t":"Japanese Holidays"}}],
"gd$recurrence":{"$t":"DTSTART..."},
"gd$eventStatus":{"value":"http://schemas.google.com/g/2005#event.confirmed"},
"gd$transparency":{"value":"http://schemas.google.com/g/2005#event.opaque"},
"gCal$uid":{"value":"egd5o1dg438h..."},
"gCal$sequence":{"value":"0"},
"gd$when":[{"startTime":"2008-01-01","endTime":"2008-01-02"}],
"gd$where":[{"valueString":""}]
}
]
}
});


参考
 Tam-calendar.js に Google Calendar の祝日データを取り込む « iDeasilo
 API Reference Guide - Google Calendar APIs and Tools - Google Code (本家リファレンス)
 API Reference Guide - Google Calendar APIs and Tools - Google Code (上記の、取得データ内容の指定についての部分)
 Using JSON with Google Data APIs - Google Data APIs - Google Code (JSONPについてなど)
 Google カレンダー利用規約
 Googleカレンダーの「日本の祝日」が間違っている | Google Mania - グーグルの便利な使い方

0 件のコメント:

ブログ アーカイブ

tags