Tui*_*Spl 7 java google-calendar-api google-meet
如何在java中的google calendar api中添加google meet?请帮我。我还没看懂谷歌文档。 https://developers.google.com/calendar/create-events。这里给出了源代码。在这里,我想使用用户 Gmail 帐户创建事件。我没有任何 G-suite 帐户
Event event = new Event()
.setSummary(title)
.setLocation(location)
.setDescription(description);
DateTime startDateTime = new DateTime( date +"T"+startTime+"+06:00" );//"2020-05-05T11:00:00+06:00");
EventDateTime start = new EventDateTime()
.setDateTime(startDateTime)
.setTimeZone("Asia/Dhaka");
event.setStart(start);
DateTime endDateTime = new DateTime(date +"T"+endTime+"+06:00");//"2020-05-05T12:00:00+06:00");
EventDateTime end = new EventDateTime()
.setDateTime(endDateTime)
.setTimeZone("Asia/Dhaka");
event.setEnd(end);
String[] recurrence = new String[] {"RRULE:FREQ=DAILY;COUNT=1"};
event.setRecurrence(Arrays.asList(recurrence));
EventAttendee attendees[];
attendees = new EventAttendee[allAttendees.size()];
for(int i=0; i<allAttendees.size(); i++){
// System.out.println(allAttendees.get(i));
attendees[i] = new EventAttendee().setEmail(allAttendees.get(i));
}
event.setAttendees(Arrays.asList(attendees));
EventReminder[] reminderOverrides = new EventReminder[] {
new EventReminder().setMethod("email").setMinutes(24 * 60),
new EventReminder().setMethod("popup").setMinutes(10),
};
Event.Reminders reminders = new Event.Reminders()
.setUseDefault(false)
.setOverrides(Arrays.asList(reminderOverrides));
event.setReminders(reminders);
String calendarId = "primary";
try {
abc = service.events().insert(calendarId, event);
} catch (IOException e) {
e.printStackTrace();
}
try {
event = service.events().insert(calendarId, event).execute();
} catch (IOException e) {
e.printStackTrace();
}
String meetingId = event.getHangoutLink();
System.out.println("What is meeting ID? = "+meetingId);
Run Code Online (Sandbox Code Playgroud)
您将需要使用Google 日历的JAVA API 文档
\n您必须创建一个新的 Meet 请求,然后将其附加到当前活动,在此之前,将conferenceDataVersion 设置为 1 来启用它。在使用以下代码之前,请确保您已进行此设置。
\nEvent event = new Event()\n .setSummary(title)\n .setLocation(location)\n .setDescription(description);\n\n// Your previous code\n\n/* The code needed - START */\n\nConferenceSolutionKey conferenceSKey = new ConferenceSolutionKey();\nconferenceSKey.setType("eventHangout"); // Non-G suite user\nCreateConferenceRequest createConferenceReq = new CreateConferenceRequest();\ncreateConferenceReq.setRequestId("3whatisup3"); // ID generated by you\ncreateConferenceReq.setConferenceSolutionKey(conferenceSKey);\nConferenceData conferenceData = new ConferenceData();\nconferenceData.setCreateRequest(createConferenceReq);\nevent.setConferenceData(conferenceData); // attach the meeting to your event\n\n/* The code needed - END */\n\nString calendarId = "primary";\n\n// There\xe2\x80\x99s no need to declare the try-catch block twice\n\ntry {\n /* Code changes - START */\n\n // .setConferenceDataVersion(1) enables the creation of new meetings\n event = service.events().insert(calendarId, event).setConferenceDataVersion(1).execute();\n\n /* Code changes - END */\n\n} catch (IOException e) {\n e.printStackTrace();\n}\n\nString meetingId = event.getHangoutLink();\nSystem.out.println("What is meeting ID? = "+meetingId);\nRun Code Online (Sandbox Code Playgroud)\nGoogle 日历 JAVA API: Event.setConferenceData\n
\nGoogle 日历 JAVA API:ConferenceData.setCreateRequest
\nGoogle 日历 JAVA API:CreateConferenceRequest.setRequestId
\nGoogle 日历 JAVA API:ConferenceSolutionKey.setType
\nGoogle Calendar JAVA API:Calendar.Events.Insert.setConferenceDataVersion 最重要
\n| 归档时间: |
|
| 查看次数: |
7933 次 |
| 最近记录: |