微信API对接SDK

1、微信开发者模式及API对接配置

2、接收和回复消息

(1)、编写消息接收Servlet,并配置到web.xml

通过继承 com.dodo.weixin.servlet.WinxinServlet 快速完成
实现2个方法:
// 获取微信自定义账户,配置文件中自定义的账户名称
public abstract String getWeChatAccount();
//添加消息接收监听器
//通过实现RequestMsgListener来自定义消息接收监听器
//通过继承RequestMsgAdapter也可以
public abstract List<RequestMsgListener> getRequestMsgListeners();

消息接收监听器,可处理以下消息

public class RequestMsgAdapter implements RequestMsgListener {
    private static final Logger LOGGER = LoggerFactory.getLogger(RequestMsgAdapter.class);

    //接收到文本消息
    public void onTextMsg(RequestMsgText msg, HttpServletRequest request) {
        LOGGER.debug("Received:", msg.toString());
    }

    //接收到图片消息
    public void onImageMsg(RequestMsgImage msg, HttpServletRequest request) {
        LOGGER.debug("Received:", msg.toString());
    }

    //收到事件推送消息
    public void onEventMsg(RequestMsgEvent msg, HttpServletRequest request) {
        LOGGER.debug("Received:", msg.toString());
    }

    //接收到链接消息
    public void onLinkMsg(RequestMsgLink msg, HttpServletRequest request) {
        LOGGER.debug("Received:", msg.toString());
    }

    //接收到LBS消息
    public void onLocationMsg(RequestMsgLocation msg, HttpServletRequest request) {
        LOGGER.debug("Received:", msg.toString());
    }

    //语音识别消息
    public void onVoiceMsg(RequestMsgVoice msg, HttpServletRequest request) {
        LOGGER.debug("Received:", msg.toString());
    }

    //接收到视频消息
    public void onVideoMsg(RequestMsgVideo msg, HttpServletRequest request) {
        LOGGER.debug("Received:", msg.toString());
    }

    //接收到错误消息
    public void onErrorMsg(RequestMsgError msg, HttpServletRequest request) {
        LOGGER.debug("Received:", msg.toString());
    }
}

(2)、将该Servlet的访问地址,配置在微信开发者模式下即完成对接

3、其他接口对接,开箱即用

//二维码相关接口
com.dodo.weixin.utils.WechatQrCodeUtil
//客服消息接口
com.dodo.weixin.utils.WeixinCustomeMsgUtil
//媒体接口
com.dodo.weixin.utils.WeixinMediaUtil
//自定义菜单接口
com.dodo.weixin.utils.WeixinMenuUtil
//多客服接口
com.dodo.weixin.utils.WeixinMultiCustomerUtil
//模板消息接口
com.dodo.weixin.utils.WeixinTemplateMsgUtil
//URL转换接口
com.dodo.weixin.utils.WeixinUrlUtil
//用户分组接口
com.dodo.weixin.utils.WeixinUserGroupUtil
//用户信息接口
com.dodo.weixin.utils.WeixinUserInfoUtil
//网页授权接口
com.dodo.weixin.utils.WeixinWebAuthUtil
Copyright © Dodo Framework 2019 all right reservedModify At: 2019-12-24 10:50:47