简体   繁体   English

Google Calendar v3 Java API:插入事件

[英]Google Calendar v3 Java API: Insert event

I am trying to insert an event into a google calendar via the java API: CalendarTest 我正在尝试通过Java API将事件插入Google日历: CalendarTest

I would like to run: 我想跑步:

new Calendar.Events.Insert(calendarId, content).execute();

except that the constructor is protected and I cannot find a static public method to do the insert. 除了构造函数受保护并且我找不到静态公共方法来执行插入操作之外。 Any suggestions? 有什么建议么?

我解决了这个问题,如下所示:

calendarClient.events().insert(appCalendarId, calendarEvent).execute();

Yes by creating object of google's Event class's type and then calling various methods for adding event to calendar :- 是的,方法是创建Google事件类类型的对象,然后调用将事件添加到日历的各种方法:

Event event = new Event();
event.setStart(new EventDateTime().setDateTime(start));
event.setEnd(new EventDateTime().setDateTime(end));
event.setSummary(eventEntity.getSummary());
event.setLocation(location);
event.setDescription(description);

after that calling following code to insert the event 之后,调用以下代码以插入事件

calendarService.events().insert(appCalendarId, calendarEvent).execute();

here the calendarService is generated from google's credentials that we get after successful response from google api 在这里,calendarService是从Google的凭据生成的,我们从google api成功响应后获得了该凭据

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

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