日程参与者操作流程
预期效果
日程展示

日程添加参与者

日程响应状态
接入流程简介
1.
id
。2.
id
,调用服务端API-添加日程参与者接口,进行日程参与者的添加操作。3.
id
,调用服务端API-获取日程参与者接口,获取日程参与人的信息。4.
id
,调用服务端API-设置日程响应邀请状态接口,进行日程参与者响应的邀请状态。5.
id
,调用服务端API-删除日程参与者接口,进行日程参与者的删除操作。步骤一:创建企业内部应用
步骤二:获取AppKey和AppSecret

步骤三:添加接口权限

步骤四:获取应用访问凭证accessToken
public void getAccessToken() throws Exception {
Config config = new Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkoauth2_1_0.Client client = new com.aliyun.dingtalkoauth2_1_0.Client(config);
GetAccessTokenRequest accessTokenRequest = new GetAccessTokenRequest()
.setAppKey("ding*********hgn")
.setAppSecret("9G_O**********xamBkhgGIO");
GetAccessTokenResponse accessToken = client.getAccessToken(accessTokenRequest);
System.out.println(JSON.toJSONString(accessToken.getBody()));
}
步骤五:调用服务端日程相关API
1.
id
。public void createCalendar() throws Exception {
Config config = new Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkcalendar_1_0.Client client = new com.aliyun.dingtalkcalendar_1_0.Client(config);
CreateEventHeaders createEventHeaders = new CreateEventHeaders();
createEventHeaders.xAcsDingtalkAccessToken = "accessToken";
java.util.Map<String, String> extra = TeaConverter.buildMap(
new TeaPair("noChatNotification", "false"),
new TeaPair("noPushNotification","false")
);
CreateEventRequest.CreateEventRequestOnlineMeetingInfo onlineMeetingInfo = new CreateEventRequest.CreateEventRequestOnlineMeetingInfo()
.setType("dingtalk");
CreateEventRequest.CreateEventRequestReminders reminders0 = new CreateEventRequest.CreateEventRequestReminders()
.setMethod("dingtalk")
.setMinutes(15);
CreateEventRequest.CreateEventRequestLocation location = new CreateEventRequest.CreateEventRequestLocation()
.setDisplayName("********A座9F");
CreateEventRequest.CreateEventRequestAttendees attendees0 = new CreateEventRequest.CreateEventRequestAttendees()
.setId("日程参与者unionId")
.setIsOptional(false);
CreateEventRequest.CreateEventRequestRecurrenceRange recurrenceRange = new CreateEventRequest.CreateEventRequestRecurrenceRange()
.setType("numbered")
.setNumberOfOccurrences(1);
CreateEventRequest.CreateEventRequestRecurrencePattern recurrencePattern = new CreateEventRequest.CreateEventRequestRecurrencePattern()
.setType("daily")
.setInterval(1);
CreateEventRequest.CreateEventRequestRecurrence recurrence = new CreateEventRequest.CreateEventRequestRecurrence()
.setPattern(recurrencePattern)
.setRange(recurrenceRange);
CreateEventRequest.CreateEventRequestEnd end = new CreateEventRequest.CreateEventRequestEnd()
.setDate("2022-09-07");
// .setDateTime("2021-09-20T10:15:30+08:00")
// .setTimeZone("Asia/Shanghai");
CreateEventRequest.CreateEventRequestStart start = new CreateEventRequest.CreateEventRequestStart()
.setDate("2022-09-07");
// .setDateTime("2021-09-20T10:15:30+08:00")
// .setTimeZone("Asia/Shanghai");
CreateEventRequest createEventRequest = new CreateEventRequest()
.setSummary("创建日程")
.setDescription("这是创建的一个日程")
.setStart(start)
.setEnd(end)
.setIsAllDay(true)
.setRecurrence(recurrence)
.setAttendees(java.util.Arrays.asList(
attendees0
))
.setLocation(location)
.setReminders(java.util.Arrays.asList(
reminders0
))
.setOnlineMeetingInfo(onlineMeetingInfo)
.setExtra(extra);
try {
CreateEventResponse eventWithOptions = client.createEventWithOptions("日程组织者unionId", "primary", createEventRequest, createEventHeaders, new RuntimeOptions());
System.out.println(JSON.toJSONString(eventWithOptions.getBody()));
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
System.out.println(err.code);
System.out.println(err.message);
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
System.out.println(err.code);
System.out.println(err.message);
}
}
}
2.
id
,调用服务端API-添加日程参与者接口,进行日程参与者的添加操作。public void addCalendarParticipants() throws Exception {
Config config = new Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkcalendar_1_0.Client client = new com.aliyun.dingtalkcalendar_1_0.Client(config);
AddAttendeeHeaders addAttendeeHeaders = new AddAttendeeHeaders();
addAttendeeHeaders.xAcsDingtalkAccessToken = "accessToken";
AddAttendeeRequest.AddAttendeeRequestAttendeesToAdd attendeesToAdd0 = new AddAttendeeRequest.AddAttendeeRequestAttendeesToAdd()
.setId("日程参与者unionId")
.setIsOptional(false);
AddAttendeeRequest.AddAttendeeRequestAttendeesToAdd attendeesToAdd1 = new AddAttendeeRequest.AddAttendeeRequestAttendeesToAdd()
.setId("日程参与者unionId")
.setIsOptional(false);
AddAttendeeRequest addAttendeeRequest = new AddAttendeeRequest()
.setAttendeesToAdd(java.util.Arrays.asList(
attendeesToAdd0,
attendeesToAdd1
));
try {
client.addAttendeeWithOptions("日程组织者unionId", "primary", "日程id", addAttendeeRequest, addAttendeeHeaders, new RuntimeOptions());
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
System.out.println(err.code);
System.out.println(err.message);
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
System.out.println(err.code);
System.out.println(err.message);
}
}
}
3.
id
,调用服务端API-获取日程参与者接口,获取日程参与人的信息。public void getCalendarParticipants() throws Exception {
Config config = new Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkcalendar_1_0.Client client = new com.aliyun.dingtalkcalendar_1_0.Client(config);
ListAttendeesHeaders listAttendeesHeaders = new ListAttendeesHeaders();
listAttendeesHeaders.xAcsDingtalkAccessToken = "accessToken";
ListAttendeesRequest listAttendeesRequest = new ListAttendeesRequest()
.setMaxResults(100);
try {
ListAttendeesResponse listAttendeesResponse = client.listAttendeesWithOptions("日程组织者unionId", "primary", "日程id", listAttendeesRequest, listAttendeesHeaders, new RuntimeOptions());
System.out.println(JSON.toJSONString(listAttendeesResponse.getBody()));
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
System.out.println(err.code);
System.out.println(err.message);
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
System.out.println(err.code);
System.out.println(err.message);
}
}
}
4.
id
,调用服务端API-设置日程响应邀请状态接口,进行日程参与者响应的邀请状态。public void setCalendarResponseStatus() throws Exception {
Config config = new Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkcalendar_1_0.Client client = new com.aliyun.dingtalkcalendar_1_0.Client(config);
RespondEventHeaders respondEventHeaders = new RespondEventHeaders();
respondEventHeaders.xAcsDingtalkAccessToken = "accessToken";
RespondEventRequest respondEventRequest = new RespondEventRequest()
.setResponseStatus("accepted");
try {
client.respondEventWithOptions("日程参与者unionId", "primary", "日程id", respondEventRequest, respondEventHeaders, new RuntimeOptions());
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
System.out.println(err.code);
System.out.println(err.message);
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
System.out.println(err.code);
System.out.println(err.message);
}
}
}
5.
id
,调用服务端API-删除日程参与者接口,进行日程参与者的删除操作。public void deleteCalendarParticipants() throws Exception {
Config config = new Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkcalendar_1_0.Client client = new com.aliyun.dingtalkcalendar_1_0.Client(config);
RemoveAttendeeHeaders removeAttendeeHeaders = new RemoveAttendeeHeaders();
removeAttendeeHeaders.xAcsDingtalkAccessToken = "accessToken";
RemoveAttendeeRequest.RemoveAttendeeRequestAttendeesToRemove attendeesToRemove0 = new RemoveAttendeeRequest.RemoveAttendeeRequestAttendeesToRemove()
.setId("日程参与者unionId");
RemoveAttendeeRequest removeAttendeeRequest = new RemoveAttendeeRequest()
.setAttendeesToRemove(java.util.Arrays.asList(
attendeesToRemove0
));
try {
client.removeAttendeeWithOptions("日程组织者unionId", "primary", "日程id", removeAttendeeRequest, removeAttendeeHeaders, new RuntimeOptions());
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
System.out.println(err.code);
System.out.println(err.message);
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
System.out.println(err.code);
System.out.println(err.message);
}
}
}
修改于 2024-01-12 07:40:58