diff --git a/pom.xml b/pom.xml index a2cb1c0..a139666 100644 --- a/pom.xml +++ b/pom.xml @@ -263,8 +263,17 @@ postgresql 42.6.0 - - + + + com.aliyun + dingtalk + 2.0.18 + + + com.aliyun + alibaba-dingtalk-service-sdk + 2.0.0 + org.apache.kafka diff --git a/src/main/java/UnitTest/TestDingTalk.java b/src/main/java/UnitTest/TestDingTalk.java new file mode 100644 index 0000000..4f93f69 --- /dev/null +++ b/src/main/java/UnitTest/TestDingTalk.java @@ -0,0 +1,34 @@ +package UnitTest; + +import com.dingtalk.api.DefaultDingTalkClient; +import com.dingtalk.api.DingTalkClient; +import com.dingtalk.api.request.OapiGettokenRequest; +import com.dingtalk.api.response.OapiGettokenResponse; +import com.taobao.api.ApiException; + +public class TestDingTalk { + + public static final String corpId = "ding0b95901147fc6be0f2c783f7214b6d69"; + public static final long agentId = 2619270936L; + public static final String appKey = "dingr94qyhpr8bflyxqz"; + public static final String appSecret = "hnxZ93QqkGJpRyBziaR2vlbOPZo1U9eeqj73DfFuFnIxIUHNPbMR2DkIol9oGteh"; + + /* + 功能:获取钉钉的Token,有效期7200秒,即2小时,每小时最好重新获取一次 + 作者:黄海 + 时间:2023-06-06 + */ + public static String getToken() throws ApiException { + DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken"); + OapiGettokenRequest request = new OapiGettokenRequest(); + request.setAppkey(appKey); + request.setAppsecret(appSecret); + request.setHttpMethod("GET"); + OapiGettokenResponse response = client.execute(request); + return response.getBody(); + } + + public static void main(String[] args_) throws Exception { + System.out.println(getToken()); + } +}