企业微信回调接口开发

企业微信配置位置 应用管理》需要回调的应用》API》接收事件服务器设置

我这里配置的回调应用是审批

保存这两个参数 Token、EncodingAESKey,还需要企业ID(位置:我的企业》企业信息》企业ID)

下载企业微信加解密库,注意事项 注意事项 注意事项

https://open.work.weixin.qq.com/api/doc/90000/90138/90307

接口 feedbackFromWx 两个请求类型Get Post具体为啥要两个看官方文档解释,主要是post接受数据我这里接收的是流程审批数据

我需要的就四个值看你们的业务需求

AgentID 应用ID
TemplateId 模版ID
SpNo 流程编号
SpStatus 流程状态


    @GetMapping("/feedbackFromWx")
    public String feedbackFromWxVerifyURL(String msg_signature, String timestamp, String nonce, String echostr) throws AesException {
        log.info("-------feedbackFromWx ------ msg_signature:{}, Long timestamp:{}, String nonce:{}, String echostr:{}",
                msg_signature, timestamp, nonce, echostr);
        String sToken = "QDG6eK";
        String sEncodingAESKey = "jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C";
        String sCorpID = "wx5823bf96d3bd56c7";
        WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID);
        String sMsg = wxcpt.VerifyURL(msg_signature, timestamp, nonce, echostr);
        log.info("sMsg:{}", sMsg);
        return sMsg;
    }

    @PostMapping("/feedbackFromWx")
    public BaseResponse<Date> feedbackFromWxData(String msg_signature, String timestamp, String nonce, @RequestBody String data)
            throws AesException, ParserConfigurationException, IOException, SAXException {
        log.info("-------feedbackFromWx ------ msg_signature:{}, Long timestamp:{}, String nonce:{}, String data:{}",
                msg_signature, timestamp, nonce, data);
        String sToken = "QDG6eK";
        String sEncodingAESKey = "jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C";
        String sCorpID = "wx5823bf96d3bd56c7";
        WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID);
        String sMsg = wxcpt.DecryptMsg(msg_signature, timestamp, nonce, data);
        log.info("sMsg:{}", sMsg);

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        StringReader sr = new StringReader(sMsg);
        InputSource is = new InputSource(sr);
        Document document = db.parse(is);

        Element root = document.getDocumentElement();
        log.info("AgentID:{}",root.getElementsByTagName("AgentID").item(0).getTextContent());
        log.info("SpNo:{}",root.getElementsByTagName("SpNo").item(0).getTextContent());
        log.info("SpStatus:{}",root.getElementsByTagName("SpStatus").item(0).getTextContent());
        log.info("TemplateId:{}",root.getElementsByTagName("TemplateId").item(0).getTextContent());

        return BaseResponse.successInstance(sMsg);
    }

 

测试一下

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值