JAVA企业微信事件接收

本文详细介绍了如何配置企业微信事件接收服务器以跟踪小程序用户添加管理员和加入企业微信群的操作。首先,通过企业微信官网设置API,包括获取Secret、绑定小程序和配置接收事件服务器。接着,使用官方提供的WXBizMsgCrypt进行验证。其次,通过用户的unionid关联企业微信客户和小程序用户,分别阐述了小程序获取unionid和企业微信获取unionid的流程。
摘要由CSDN通过智能技术生成


前言

接上文步骤,通过小程序引流到企业微信中,需要追踪小程序的用户添加企业微信管理员以及加入企业微信群的情况,本文记录了如何去关联

一、企业微信事件接收服务器

通过配置企业微信事件接收服务,当客户有添加企业微信管理员的时候,企业微信会通知导服务器,从而知道小程序引流的用户的后续动作

1、配置企业微信事件接收服务器

登录企业微信官网,打开客户联系–>客户页面,点开api按钮
在这里插入图片描述
a、获取Secret
b、绑定对应的微信小程序
c、配置接收事件服务器
在这里插入图片描述
输入接收通知url地址,token以及EncodingAESKey保存的时候,通知服务器会接收到一条验证请求,需要返回解析好的参数才能通过验证,具体代码如下:

	public class QywxController extends BaseController{
   

    @Autowired
    private QywxService qywxService;

    @RequestMapping(value = "/change",method = {
   RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String change(@RequestParam("msg_signature") String signature, @RequestParam("timestamp") String timestamp, @RequestParam("nonce") String nonce,@RequestParam(value = "echostr") String echostr) throws Exception {
   
        return qywxService.verifyUrl(signature,timestamp,nonce,echostr);
    }

}

public class QywxService {
   

    @Value("${qywxCorpid}")
    private String sCorpID;

    @Value("${qywxMsgReplyToken}")
    private String token;

    @Value("${qywxEncodingAESKey}")
    private String encodingAESKey;

    public String verifyUrl(String signature, String timestamp, String nonce,String echostr) throws AesException {
   
        WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(token, encodingAESKey, sCorpID);
        return wxcpt.VerifyURL(signature,t
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会写代码的健身教练

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值