开发者社区> 问答> 正文

钉钉日志控件是怎么做的?

钉钉日志控件是怎么做的?

展开
收起
程旭清 2020-04-14 16:54:41 900 0
1 条回答
写回答
取消 提交回答
  • 通过访问钉钉开放API来实现访问日志信息,很简单。

    package dataBackup;
     
    import java.util.concurrent.TimeUnit;
     
    import com.dingtalk.api.DefaultDingTalkClient;
    import com.dingtalk.api.DingTalkClient;
    import com.dingtalk.api.request.OapiGettokenRequest;
    import com.dingtalk.api.request.OapiReportListRequest;
    import com.dingtalk.api.response.OapiGettokenResponse;
    import com.dingtalk.api.response.OapiReportListResponse;
    import com.taobao.api.ApiException;
     
    public class dataBackup {
    	public static void main(String []args) throws ApiException {
    		//获取accessToken实现免登陆
    		DefaultDingTalkClient cli = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
    		OapiGettokenRequest req = new OapiGettokenRequest();
    		req.setAppkey("appkey");
    		req.setAppsecret("appsecret");
    		req.setHttpMethod("GET");
    		OapiGettokenResponse res = cli.execute(req);
    		String accessToken = res.getAccessToken();
    		//获取当天日志信息
    		DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/report/list");
    		OapiReportListRequest request = new OapiReportListRequest();
    		request.setTemplateName("日报");
    		request.setStartTime(System.currentTimeMillis()-TimeUnit.DAYS.toMillis(10));
    		request.setEndTime(System.currentTimeMillis());
    		request.setCursor(0L);
    		request.setSize(10L);
    		OapiReportListResponse response = client.execute(request, accessToken);
    		//解码获取的日志json格式文件
    		String logInfo = response.getBody();
    		System.out.println(logInfo);
    	}
    }
    
    2020-04-15 22:33:21
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
钉钉小程序——为工作方式插上翅膀 立即下载
钉钉客户端自动化的应用 立即下载
使命必达 —— 钉钉企业级 消息服务的机遇与挑战 立即下载