开发者社区> 问答> 正文

钉钉回调接口验证通过了 但是还是没法监控审批流程???




         /**url中的签名**/
           String msgSignature = request.getParameter("signature");
           /**url中的时间戳**/
           String timeStamp = request.getParameter("timestamp");
           /**url中的随机字符串**/
           String nonce = request.getParameter("nonce");
        /**对encrypt进行解密**/
        DingTalkEncryptor dingTalkEncryptor = null;
        try {
            dingTalkEncryptor = new DingTalkEncryptor(GlobalConstant.ding_token, GlobalConstant.ding_aes_key, GlobalConstant.ding_CorpID);
            //dingTalkEncryptor = new DingTalkEncryptor("123456", "4g5j64qlyl3zvetqxz5jiocdr586fn2zvjpa8zls3ij", "suite4xxxxxxxxxxxxxxx");
            
            /**post数据包数据中的加密数据**/
               ServletInputStream sis =  request.getInputStream();
               BufferedReader br = new BufferedReader(new InputStreamReader(sis));
               String line = null;
               StringBuilder sb = new StringBuilder();
               while((line = br.readLine())!=null){
                sb.append(line);
               }
               System.out.println("sb:"+sb.toString());
               JSONObject jsonEncrypt = JSONObject.parseObject(sb.toString());
                String encrypt = jsonEncrypt.getString("encrypt");
                
                if(encrypt!=null && !"".equals(encrypt)){
                //对于DingTalkEncryptor的第三个参数,ISV进行配置的时候传对应套件的SUITE_KEY,普通企业传Corpid
                System.out.println("msgSignature:"+msgSignature+";timeStamp:"+timeStamp+";nonce:"+nonce);
                System.out.println("encrypt:"+encrypt);
                String plainText = dingTalkEncryptor.getDecryptMsg(msgSignature, timeStamp, nonce, encrypt);
                JSONObject plainTextJson = JSONObject.parseObject(plainText);        
                String eventType = plainTextJson.getString("EventType");
                System.out.println("eventType:"+eventType);
                switch (eventType){
                case "bpms_instance_change"://流程实例监控 "processInstanceId": "ad253df6-e175caf-68085c60ba8a",
                    System.out.println("Instance"+plainTextJson.getString("title")+":"+plainTextJson.getString("bizCategoryId")+":"+plainTextJson.getString("type")+":"+plainTextJson.getString("staffId"));
                    break;
                case "bpms_task_change"://流程实例监控 "processInstanceId": "ad253df6-e175caf-68085c60ba8a",
                    System.out.println("Task"+plainTextJson.getString("title")+":"+plainTextJson.getString("bizCategoryId")+":"+plainTextJson.getString("type")+":"+plainTextJson.getString("staffId"));
                    break;
                case "check_url":
                {
                    System.out.println("check_url");
                    break;
                }
                default : //do something
                    System.out.println("bpms_instance_change Errrrrrrrrrrrrror");
                    break;
                }
                }
                /**对返回信息进行加密**/
                long timeStampLong = Long.parseLong(timeStamp);
                Map<String,String> jsonMap = null;
                try {
                    jsonMap = dingTalkEncryptor.getEncryptedMap("success", timeStampLong, nonce);
                } catch (DingTalkEncryptException e) {
                    System.out.println(e.getMessage());
                    e.printStackTrace();
                }
                JSONObject json = new JSONObject();
                json.putAll(jsonMap);    
                response.getWriter().append(json.toString());    
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    上面是回调接口的代码,首次注册的时候已经打印check_url并且返回了加密的“”success“”字符串,但是我在钉钉中发起流程,回调接口并没有监控流程事件,求大神指教指教 哪里出现问题了

展开
收起
AndyWong 2017-08-23 09:00:41 8478 0
4 条回答
写回答
取消 提交回答
  • iuv
    Re钉钉回调接口验证通过了 但是还是没法监控审批流程???
    这个设计太傻X了。“只有通过开放接口创建的审批才能回调”。太傻太傻!!!
    2018-07-30 18:04:25
    赞同 展开评论 打赏
  • hen gao xing yu jian ni
    回 2楼杨万里的帖子
    是的, 只有接口发起的审批, 才能回调!
    我也是自己企业介入的, 可以加qq多多交流, 281487050
    2018-04-26 11:14:26
    赞同 展开评论 打赏
  • 回 1楼东方不能败的帖子
    也就是说,钉钉不能主动回调,只有服务器发起审批实例,钉钉才能回调么?
    2018-04-25 08:35:25
    赞同 展开评论 打赏
  • Re钉钉回调接口验证通过了 但是还是没法监控审批流程???
    只有通过开放接口发起的审批才会有回调
    2018-01-29 13:45:55
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

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