# fastweixin **Repository Path**: geekcheng/fastweixin ## Basic Information - **Project Name**: fastweixin - **Description**: fastweixin简单封装了所有与微信服务器交互的消息:文本消息、图片消息、图文消息等等。 提供了基于springmvc以及基于servlet框架的控制器,集成了微信服务器绑定、监听所有类型消息的方法 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2014-09-17 - **Last Updated**: 2024-12-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README fastweixin ========== 作者:peiyu
[关注我](http://weibo.com/1728407960)
QQ:125331682
#快速搭建微信公众平台服务器
简单封装了所有与微信服务器交互的消息:文本消息、图片消息、图文消息等等
提供了基于`springmvc`以及基于`servlet`框架的控制器,集成了微信服务器绑定、监听所有类型消息的方法
使用时继承,重写即可,十分方便
##基于`springmvc`项目的集成方法 ```Java @RestController @RequestMapping("/weixin") public class WeixinController extends WeixinControllerSupport { private static final Logger log = LoggerFactory.getLogger(WeixinController.class); private static final String TOKEN = "myToken"; //设置TOKEN,用于绑定微信服务器 @Override protected String getToken() { return TOKEN; } //重写父类方法,处理对应的微信消息 @Override protected BaseMsg handleTextMsg(TextReqMsg msg) { String content = msg.getContent(); log.debug("用户发送到服务器的内容:{}", content); return new TextMsg("服务器回复用户消息!"); } //1.1版本新增,重写父类方法,加入自定义微信消息处理器 @Override protected List getMessageHandles() { List handles = new ArrayList(); handles.add(new MyMessageHandle()); return handles; } //1.1版本新增,重写父类方法,加入自定义微信事件处理器 @Override protected List getEventHandles() { List handles = new ArrayList(); handles.add(new MyEventHandle()); return handles; } } ``` ##基于`servlet`项目的集成方法 ```Java public class WeixinServlet extends WeixinServletSupport { private static final Logger log = LoggerFactory.getLogger(WeixinController.class); private static final String TOKEN = "myToken"; //设置TOKEN,用于绑定微信服务器 @Override protected String getToken() { return TOKEN; } //重写父类方法,处理对应的微信消息 @Override protected BaseMsg handleTextMsg(TextReqMsg msg) { String content = msg.getContent(); log.debug("用户发送到服务器的内容:{}", content); return new TextMsg("服务器回复用户消息!"); } //1.1版本新增,重写父类方法,加入自定义微信消息处理器 @Override protected List getMessageHandles() { List handles = new ArrayList(); handles.add(new MyMessageHandle()); return handles; } //1.1版本新增,重写父类方法,加入自定义微信事件处理器 @Override protected List getEventHandles() { List handles = new ArrayList(); handles.add(new MyEventHandle()); return handles; } } ```
web.xml配置 ```xml weixin xxx.xxx.WeixinServlet weixin /weixin ``` Change Log ========= [https://github.com/sd4324530/fastweixin/wiki/Change-Log](https://github.com/sd4324530/fastweixin/wiki/Change-Log) Why Use ========= [https://github.com/sd4324530/fastweixin/wiki/Why-use](https://github.com/sd4324530/fastweixin/wiki/Why-use) Maven 项目引入 ========== ```xml com.github.sd4324530 fastweixin 1.1 ``` 开源协议 ========== [Apache License](http://www.apache.org/licenses/LICENSE-2.0)