开发者社区> 问答> 正文

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

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

展开
收起
程旭清 2020-04-14 16:54:41 896 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
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PostgresChina2018_赖思超_PostgreSQL10_hash索引的WAL日志修改版final 立即下载
Kubernetes下日志实时采集、存储与计算实践 立即下载
日志数据采集与分析对接 立即下载