我想使用 JavaScript 从 Google Calendar API 中提取某些国家/地区的假期列表。
有可能吗?我怎样才能做到这一点?
是的,使用 Google API 您可以做到这一点。
从“Credentials”选项卡中,您可以创建一个 API 密钥,您将获得 像这样的东西
AIzaSyBcOT_DpEQysiwFmmmZXupKpnrOdJYAhhM
然后,您可以使用此 URL 访问假期日历
https://www.googleapis.com/calendar/v3/calendars/en.uk%23holiday%40group.v.calendar.google.com/events?key=<YOUR API KEY>
google 提供假期列表 API。
然后,更改 url 中的文本
calendars/en.usa
在此之后,
像这样
"items": [
{
"kind": "calendar#event",
"etag": "\"3101513576000000\"",
"id": "20200101_60o30dr46oo30c1g60o30dr56g",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=MjAyMDAxMDFfNjBvMzBkcjQ2b28zMGMxZzYwbzMwZHI1NmcgZW4udXNhI2hvbGlkYXlAdg",
"created": "2019-02-21T13:46:28.000Z",
"updated": "2019-02-21T13:46:28.000Z",
"summary": "New Year's Day",
"creator": {
"email": "en.usa#[email protected]",
"displayName": "Holidays in United States",
"self": true
},
"organizer": {
"email": "en.usa#[email protected]",
"displayName": "Holidays in United States",
"self": true
},
"start": {
"date": "2020-01-01"
},
"end": {
"date": "2020-01-02"
},
"transparency": "transparent",
"visibility": "public",
"iCalUID": "[email protected]",
"sequence": 0
},
{
.........
我们将在那里获得所有细节,例如, “摘要”键中的节日名称
"summary": "New Year's Day",
https://gist.github.com/dhoeric/76bd1c15168ee0ee61ad3bf1730dcb65
这是所有国家/地区的列表。
需要更换
en.indian.official#[email protected]
在网址中。
突出显示的部分需要更换。 如果您收到身份验证错误,请更换
#
与 %23
和
@
与 %40
由于一些解析问题,它会带来身份验证问题。