| | |
| | | */ |
| | | @Override |
| | | public String getDingTalkUserByMobile(String mobile) throws Exception { |
| | | String userId = ""; |
| | | String accessToken = getAccessToken(); |
| | | DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/getbymobile"); |
| | | OapiV2UserGetbymobileRequest req = new OapiV2UserGetbymobileRequest(); |
| | | req.setMobile(mobile); |
| | | OapiV2UserGetbymobileResponse rsp = client.execute(req, accessToken); |
| | | return rsp.getBody(); |
| | | String resultBody = rsp.getBody(); |
| | | JSONObject json = JSONObject.parseObject(resultBody); |
| | | if("0".equals(json.get("errcode"))){ |
| | | userId = json.getJSONObject("result").getString("userid"); |
| | | } |
| | | return userId; |
| | | } |
| | | |
| | | } |