微信公众号自动回复简单实现

第一步:配置接口配置信息

测试账号在 http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index网页中配置    接口配置信息

配置参考微信测试账号管理-配置接口信息

如果是开发账号请在https://mp.weixin.qq.com/advanced/advanced?action=interface&t=advanced/interface&token=637985175&lang=zh_CN配置页面如下

第二步:修改接收微信响应接口如下

package com.wl.wechat.contoller;

import com.wl.wechat.model.WxMessageTemplate;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext;
import java.io.InputStream;
import java.util.Arrays;

/**
 * Created by wl on 2021/4/10.
 */
@RestController
@RequestMapping("/wx")
public class WxController {

    private static final String TOKEN = "wl123";

    @RequestMapping("/receiveWx")
    public void receiveWxToken(HttpServletRequest request,HttpServletResponse response) throws Exception{

        String signature = request.getParameter("signature");
        String timestamp = request.getParameter("timestamp");
        String nonce = request.getParameter("nonce");
        String echostr = request.getParameter("echostr");
   
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值