简体   繁体   English

Google Calendar API公共假期

[英]Google Calendar API public holidays

Using the Node https://github.com/google/google-api-nodejs-client liibrary I am trying to access public holidays. 我正在尝试使用Node https://github.com/google/google-google-api-nodejs-client库来访问公共假期。 I havve the auth working and have access to the API. 我拥有身份验证功能并可以访问API。 When I test the events.list endpoints with API explorer it works, I suspect that the calendar 当我使用API​​资源管理器测试events.list端点时,它可以工作,我怀疑日历

calendarId :'en.sa#holiday@group.v.calendar.google.com' calendarId:'en.sa#holiday@group.v.calendar.google.com'

exists in my personal calendar but not in the apps calendar. 存在于我的个人日历中,但不存在于应用程序日历中。

When I try to get the list of calendars in my node app the list is empty: 当我尝试在节点应用程序中获取日历列表时,该列表为空:

calendar.calendarList.list({auth: jwtClient}, calenderGetComplete);

So the events.list doesnt find the calendar. 因此events.list找不到日历。

calendar.events.list({ calendarId :'en.sa#holiday@group.v.calendar.google.com', auth: jwtClient}, calenderGetComplete);

So on a personal calendar one can add other interesting calendars, like the public holiday one, but seems like you cant do it for the calendar the app is using? 因此,在个人日历上,可以添加其他有趣的日历,例如公共假期,但是似乎无法为应用程序使用的日历添加日历? Seems like the public calendars doesn't have 'interesting calendars'? 似乎公共日历没有“有趣的日历”?

I am not sure how it is you are authenticating Oauth2 or a service account? 我不确定您如何验证Oauth2或服务帐户?

There is a difference between calendar list and calendar. 日历列表和日历之间有区别。 Calendar list is just that little list on the bottom left hand side of the google calendar website it has no real purpose (IMO). 日历列表只是Google日历网站左下角的那个小列表,没有实际用途(IMO)。 If you are using a service account and grant it access to one of your personal (ex: chrisMalherbe at gmail.com) Google calendars it will have access to it but it wont appear in the service accounts calendar.list unless you insert it there manually. 如果您正在使用服务帐户并授予其访问您的个人Google日历(例如:gmail.com上的chrisMalherbe)的权限,它将有权使用该帐户,但除非您手动将其插入其中,否则它不会出现在服务帐户calendar.list中。 。 When you add one of these interesting calendars to your personal google calendar page (ex: chrisMalherbe at gmail.com) the website automatically adds it to calendar.list for you. 当您将这些有趣的日历之一添加到您的个人Google日历页面(例如:gmail.com上的chrisMalherbe)时,网站会自动为您添加到calendar.list。

It doesn't really need to be there. 它实际上并不需要在那里。

As for public calendars everyone has access and they don't need to be in calendar list. 至于公共日历,每个人都可以访问,而不必进入日历列表。 They are public you can create a public API key and request data from them. 它们是公共的,您可以创建公共API密钥并向其请求数据。 I am not sure what calendar en.sa is but I would take your API key and dump this in a web browser just to make sure there is data. 我不确定日历en.sa是什么,但是我会拿您的API密钥并将其转储到Web浏览器中只是为了确保有数据。 If memory serves there are a few with no data, and the data only goes a year a head I think so if you are looking for holidays in 2020 there wont be any data. 如果内存可用,则有一些没有数据,而我认为这些数据只会提前一年,因此,如果您正在寻找2020年的假期,那么将不会有任何数据。

GET https://www.googleapis.com/calendar/v3/calendars/en.sa#holiday@group.v.calendar.google.com/events?key=[APIKey]

Or with an access token if you don't want to use public API key 或使用访问令牌(如果您不想使用公共API密钥)

GET https://www.googleapis.com/calendar/v3/calendars/en.sa#holiday@group.v.calendar.google.com/events?access_token=[accesstoken]

I am not a node.js expert but I found this node-google-api it might help I have a tutorial on this its mostly explains how public calendars work however its in C# may or may not be of any help to you. 我不是node.js专家,但是我发现此node-google-api可能有帮助。我对此有一个教程,该教程主要介绍了公共日历的工作原理,但是C#中的公共日历可能对您没有帮助。 Public Google Calendars with C# 使用C#的公开Goog​​le日历

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM