亚洲免费在线视频-亚洲啊v-久久免费精品视频-国产精品va-看片地址-成人在线视频网

您的位置:首頁技術(shù)文章
文章詳情頁

JAVA maven項目使用釘釘SDK獲取token、用戶

瀏覽:98日期:2022-05-29 11:23:00

本文介紹了JAVA maven項目使用釘釘SDK獲取token、用戶,分享給大家,具體如下:

JAVA maven項目使用釘釘SDK獲取token、用戶

將SDK放一個文件里,記住文件地址。D:eclipse-workspace項目名模塊名lib

win+r cmd 敲下面的命令:

【進入相應(yīng)盤】 D:

【進入文件地址】 cd D:eclipse-workspace項目名模塊名

【運行命令】 mvn install:install-file -DgroupId=com.dingtalk.api -DartifactId=top-api-sdk-dev -Dversion=ding-open-mc-SNAPSHOT -Dfile=lib/taobao-sdk-java-auto_1479188381469-20200319.jar -Dpackaging=jar -DgeneratePom=true

JAVA maven項目使用釘釘SDK獲取token、用戶

然后在pom文件中增加以下內(nèi)容:

<!--釘釘工具包--> <dependency> <groupId>com.dingtalk.api</groupId> <artifactId>top-api-sdk-dev</artifactId> <version>ding-open-mc-SNAPSHOT</version> </dependency>

理解:普通的maven項目都會在pom里配置好jar,項目自動從maven中配置的鏡像地址(就是網(wǎng)上)自己把jar包下載到你設(shè)置的位置

但是有些jar包下載不下來,可以先本地保存,然后像上面那樣用命令把jar包掛到maven設(shè)置的jar庫里去

JAVA后臺代碼:

import com.dingtalk.api.DefaultDingTalkClient;import com.dingtalk.api.DingTalkClient;import com.dingtalk.api.request.OapiDepartmentListRequest;import com.dingtalk.api.request.OapiGettokenRequest;import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;import com.dingtalk.api.request.OapiUserSimplelistRequest;import com.dingtalk.api.response.OapiDepartmentListResponse;import com.dingtalk.api.response.OapiGettokenResponse;import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;import com.dingtalk.api.response.OapiUserSimplelistResponse;import com.taobao.api.ApiException;import com.dingtalk.api.response.OapiDepartmentListResponse.Department;import com.dingtalk.api.request.*;import com.dingtalk.api.response.*;。。。 登錄接口方法(前端傳來code){// 釘釘 /gettoken 獲取token,只需填寫appkey和appsecret try { DingTalkClient client1 = new DefaultDingTalkClient('https://oapi.dingtalk.com/gettoken'); OapiGettokenRequest req1 = new OapiGettokenRequest(); req1.setAppkey('xxxxxxxx'); req1.setAppsecret('xxxxxxxx'); req1.setHttpMethod('GET'); OapiGettokenResponse rsp1 = client1.execute(req1); System.out.println(rsp1.getBody()); accessToken = rsp1.getAccessToken(); } catch (Exception e) { //} catch (ApiException e) { e.printStackTrace(); } // 釘釘 /user/getuserinfo 獲取用戶userid try { DingTalkClient client2 = new DefaultDingTalkClient('https://oapi.dingtalk.com/user/getuserinfo'); OapiUserGetuserinfoRequest req2 = new OapiUserGetuserinfoRequest(); req2.setCode(code);// req2.setHttpMethod('GET'); OapiUserGetuserinfoResponse rsp2 = client2.execute(req2, accessToken);// System.out.println(rsp2.getBody()); userId = rsp2.getUserid(); System.out.println('userId:' + userId); System.out.println('------------------------------------------------------'); } catch (ApiException e) { e.printStackTrace(); } // 釘釘 /user/get 獲取用戶詳情 try {DingTalkClient client3 = new DefaultDingTalkClient('https://oapi.dingtalk.com/user/get');OapiUserGetRequest req3 = new OapiUserGetRequest();req3.setUserid(userId);//req3.setHttpMethod('GET');OapiUserGetResponse rsp3 = client3.execute(req3, accessToken);//System.out.println(rsp3.getBody()); } catch (ApiException e) {e.printStackTrace(); } // 釘釘 獲取所有部門列表try { DingTalkClient client4 = new DefaultDingTalkClient('https://oapi.dingtalk.com/department/list'); OapiDepartmentListRequest req4 = new OapiDepartmentListRequest(); req4.setHttpMethod('GET'); req4.setId('1'); OapiDepartmentListResponse rsp4 = client4.execute(req4, accessToken); System.out.println('-----------------獲取所有部門列表-----------------'); System.out.println(rsp4.getBody()); List<Department> departmentList = rsp4.getDepartment(); System.out.println('-----------------------------------------------------'); // [{id: xxx, parentid: xxx, ......},{id: xxx, parentid: xxx, ......},{id: xxx, parentid: xxx, ......},{id: xxx, parentid: xxx, ......}] System.out.println(departmentList.get(0).getId();  Long parentid = departmentList.get(0).getParentid(); } catch (ApiException e) { e.printStackTrace(); } }

到此這篇關(guān)于JAVA maven項目使用釘釘SDK獲取token、用戶的文章就介紹到這了,更多相關(guān)maven 釘釘SDK獲取token、用戶內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: 釘釘
相關(guān)文章:
主站蜘蛛池模板: 国内精品线在线观看 | 国产精品亚洲一区二区三区久久 | 亚洲国产一区二区三区最新 | 欧洲成人全免费视频网站 | 久久福利资源网站免费看 | 日本在线观看不卡免费视频 | 99国产精品热久久久久久夜夜嗨 | 在线免费观看日本视频 | 日本视频在线免费观看 | 欧美怡红院免费的视频 | 欧美三级观看 | 韩国在线精品福利视频在线观看 | 在线观看欧洲成人免费视频 | 国产成人综合欧美精品久久 | 久久的精品99精品66 | 欧美一级片在线看 | 亚洲国产精品综合久久 | 怡红院在线观看 | 日韩女人做爰大片 | 久草网在线观看 | 国产日本韩国不卡在线视频 | 国产真实一区二区三区 | 一级爱爱片一级毛片-一毛 一级爱做片免费观看久久 一级白嫩美女毛片免费 | 国产三级日本三级在线播放 | 亚洲一区在线免费观看 | 国产成人精品久久综合 | 免费欧洲毛片a级视频 | 久久在线视频播放 | 精品国产一区二区三区2021 | 色综合久久88色综合天天提莫 | 精品一区二区三区波多野结衣 | 欧洲成人r片在线观看 | 日本美女高清在线观看免费 | 欧美黄色特级视频 | 国产成人免费视频 | 经典三级久久久久 | 天天看片天天爽_免费播放 天天看夜夜 | 日本特黄特色视频 | 国产女人毛片 | 97在线视频免费公开观看 | 国产精品亚洲第一区二区三区 |