获取钉钉考勤结果
- 开发笔记
- 2024/1/25 17:08:10
- 人已阅读
简介
void getKaoQingResult() { var client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/list"); OapiAttendanceListRequest req = new OapiAttendanceListRequest(); req.WorkDateFrom = "2023-5-5 08:00:00"; req.WorkDateTo = "2024-5-5 18:00:00"; req.UserIdList = new System.Collections.Generic.List<string> { "" }; req.Offset = (0L); req.Limit = (10L); req.IsI18n = (true); var access_token = GetDingTalkToken(new DingTalkAppInfo { //CorpId = "ding8c0b6f11ba7f1fd335c2f4657eb6378f", //AgentId = "1280872356", AppKey = "ding2y2fksnq3olbo2z7", AppSecret = "3fNgsdR5NCQZOa6yPReWYWMujoV1BSsu2g1n_W_GzTyNqgjeE38nukchelcShAsK" }); OapiAttendanceListResponse rsp = client.Execute(req, access_token); dynamic entity = JsonHelper.Deserialize<dynamic>(rsp.Body); if (entity.errcode != 0) throw new Exception("获取钉钉结果异常:" + entity.errmsg); var result = rsp.Body;//60001没有接口权限 } /// <summary> /// 获取钉钉Token /// </summary> /// <returns></returns> private static string GetDingTalkToken(DingTalkAppInfo DingTalkAppInfo) { IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken"); OapiGettokenRequest req = new OapiGettokenRequest() { Appkey = DingTalkAppInfo.AppKey, Appsecret = DingTalkAppInfo.AppSecret }; req.SetHttpMethod("GET"); OapiGettokenResponse rsp = client.Execute(req); dynamic entity = JsonHelper.Deserialize<dynamic>(rsp.Body); if (entity.errcode != 0) throw new Exception("获取钉钉Token异常:" + entity.errmsg); var Token = entity.access_token;//最好是缓存下 return Token; }
上一篇:时间戳转为C#格式时间
文章评论
- 消灭零回复