如何为自定义持续时间加载 google ics 文件?

How to load google ics file for custom duration date?

我想从 google 日历同步事件以保存到 mysql 数据库。当我从 google 日历检查它时,它提供了 ics url 文件,我可以将它加载到我的程序中。但它提供了所有事件。如何按自定义日期获取事件?

答案:

很遗憾,这是不可能的。

更多信息:

ICS 格式是一种通用日历格式,设计用于在应用程序之间轻松发送事件和安排数据。

虽然可以创建包含 Google 日历所有详细信息的 ICS 文件,但 Google 不提供允许您按自定义日期选择事件的方法,至少通过API.

解决方法:

您可以使用 Google Calendar API - specifically the Events: list method to get a list of events, specifying the time frame for which you wish to retrieve events, but from there you will either have to process the response in a different way (the API response comes in a JSON file as demonstrated here),否则您必须先将此数据转换为 iCalendar 格式,然后再将其放入数据库。

参考文献: