DingUtil.java 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.fjhx.utils;
  2. //import com.dingtalk.api.DefaultDingTalkClient;
  3. //import com.dingtalk.api.DingTalkClient;
  4. //import com.dingtalk.api.request.OapiServiceGetCorpTokenRequest;
  5. //import com.dingtalk.api.request.OapiV2DepartmentGetRequest;
  6. //import com.dingtalk.api.request.OapiV2DepartmentListsubRequest;
  7. //import com.dingtalk.api.request.OapiV2UserGetRequest;
  8. //import com.dingtalk.api.response.OapiServiceGetCorpTokenResponse;
  9. //import com.dingtalk.api.response.OapiV2DepartmentGetResponse;
  10. //import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
  11. //import com.dingtalk.api.response.OapiV2UserGetResponse;
  12. //import com.taobao.api.ApiException;
  13. public class DingUtil {
  14. // private static final String accessKey = "suitepgu4shlatgllyiqp";
  15. // private static final String accessSecret = "52-_2aKc3WGd8qVX5FRFmR6MnkeAOi6seUKYxjMWBCeiXZJ0l01_YaDfABIP-hmk";
  16. //
  17. // public static void main(String[] args) throws ApiException {
  18. // OapiServiceGetCorpTokenResponse corpToken = getCorpToken("ding53d823e205604918a39a90f97fcb1e09",
  19. // "R9lsfWBExszmJuiJwF8gd3LQ31YUnUaPRQ0L0W4CsslEsyM1L5GVfLXPJExnhbqRsLntMnFp7KYCha9msIjRCY");
  20. //
  21. // if (corpToken.getErrcode().equals(0L)) {
  22. // String accessToken = corpToken.getAccessToken();
  23. // getDeptList(accessToken, 1L);
  24. //
  25. // }
  26. // }
  27. //
  28. // /**
  29. // * 获取token
  30. // */
  31. // public static OapiServiceGetCorpTokenResponse getCorpToken(String authCorpid, String suiteTicket) throws ApiException {
  32. //
  33. // DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/service/get_corp_token");
  34. // OapiServiceGetCorpTokenRequest req = new OapiServiceGetCorpTokenRequest();
  35. // req.setAuthCorpid(authCorpid);
  36. //
  37. // return client.execute(req, accessKey, accessSecret, suiteTicket);
  38. // }
  39. //
  40. // public static void getDeptList(String accessToken, Long deptId) throws ApiException {
  41. // DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
  42. // OapiV2DepartmentListsubRequest req = new OapiV2DepartmentListsubRequest();
  43. // req.setDeptId(deptId);
  44. // OapiV2DepartmentListsubResponse rsp = client.execute(req, accessToken);
  45. //
  46. // List<OapiV2DepartmentListsubResponse.DeptBaseResponse> result = rsp.getResult();
  47. //
  48. // for (OapiV2DepartmentListsubResponse.DeptBaseResponse deptBaseResponse : result) {
  49. // getDeptList(accessToken, deptBaseResponse.getDeptId());
  50. //
  51. // getDeptDetails(accessToken,deptBaseResponse.getDeptId());
  52. // }
  53. //
  54. // }
  55. //
  56. // public static void getDeptDetails(String accessToken, Long deptId) throws ApiException {
  57. // DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/get");
  58. // OapiV2DepartmentGetRequest req = new OapiV2DepartmentGetRequest();
  59. // req.setDeptId(deptId);
  60. // OapiV2DepartmentGetResponse rsp = client.execute(req, accessToken);
  61. // System.out.println(rsp.getBody());
  62. // }
  63. //
  64. //
  65. // public static void getUser(String accessToken, String userId) throws ApiException {
  66. // DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
  67. // OapiV2UserGetRequest req = new OapiV2UserGetRequest();
  68. // req.setUserid(userId);
  69. // OapiV2UserGetResponse rsp = client.execute(req, accessToken);
  70. // System.out.println(rsp.getBody());
  71. // }
  72. }