jeewx的使用_01 接入和验证
2016-02-25 11:07
260 查看
jeewx是java语言的用于开发微信公共平台的一个框架,有人说很臃肿,但个人感觉还不错,仁者见仁智者见智吧,
下面简单介绍工作原理:
1、下载
要使用jeewx需要先下载其源码
jeewx介绍:http://www.oschina.net/p/jeewx
下载地址:http://git.oschina.net/jeecg/jeewx
2、使用
首先要在安装好的jeewx中填写需要二次开发的微信公众号的基本信息
然后登录微信公众平台,在基本设置中填写url
URL(服务器地址)
http://域名/jeewx/wechatController.do?wechat 当开发者填写了服务器配置后,用户消息和开发者需要的事件推送,将会被转发到该URL中
3、打开WechatController.java
可以看到当微信的服务器把request推送到该controller之后,剩下的工作就有wechatService来完成了,由于我的wechatService已经经过修改,这里就不在贴出,相信有java基础的博友一看便知,
下面简单介绍工作原理:
1、下载
要使用jeewx需要先下载其源码
jeewx介绍:http://www.oschina.net/p/jeewx
下载地址:http://git.oschina.net/jeecg/jeewx
2、使用
首先要在安装好的jeewx中填写需要二次开发的微信公众号的基本信息
然后登录微信公众平台,在基本设置中填写url
URL(服务器地址)
http://域名/jeewx/wechatController.do?wechat 当开发者填写了服务器配置后,用户消息和开发者需要的事件推送,将会被转发到该URL中
3、打开WechatController.java
package weixin.guanjia.core.controller; import java.io.IOException; import java.io.PrintWriter; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import weixin.guanjia.account.entity.WeixinAccountEntity; import weixin.guanjia.account.service.WeixinAccountServiceI; import weixin.guanjia.core.service.impl.WechatService; import weixin.guanjia.core.util.SignUtil; @Controller @RequestMapping("/wechatController") public class WechatController { @Autowired private WechatService wechatService; @Autowired private WeixinAccountServiceI weixinAccountService; /** * 与微信对接的接口 * @注释添加 geenkDC * @time 2015-07-09 14:34:07 * @param request * @param response * @param signature * @param timestamp * @param nonce * @param echostr */ @RequestMapping(params="wechat", method = RequestMethod.GET) public void wechatGet(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "signature") String signature, @RequestParam(value = "timestamp") String timestamp, @RequestParam(value = "nonce") String nonce, @RequestParam(value = "echostr") String echostr) { List<WeixinAccountEntity> weixinAccountEntities = weixinAccountService.getList(WeixinAccountEntity.class); for (WeixinAccountEntity account : weixinAccountEntities) { if (SignUtil.checkSignature(account.getAccounttoken(), signature, timestamp, nonce)) { try { response.getWriter().print(echostr); break; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } /** * 统一接收微信服务器推送的接口 * @注释添加 geenkDC * @time 2015-07-09 14:34:56 * @param response * @param request * @throws IOException */ @RequestMapping(params = "wechat", method = RequestMethod.POST) public void wechatPost(HttpServletResponse response, HttpServletRequest request) throws IOException { String respMessage = wechatService.coreService(request); PrintWriter out = response.getWriter(); out.print(respMessage); out.close(); } }
可以看到当微信的服务器把request推送到该controller之后,剩下的工作就有wechatService来完成了,由于我的wechatService已经经过修改,这里就不在贴出,相信有java基础的博友一看便知,
相关文章推荐
- H5+ and mui学习记录
- 摄像头/光驱故障:由于其配置信息(注册表中的)不完整或已损坏,Windows 无法启动这个硬件设备。 (代码 19)
- Office 2010/2007 简繁体转换按钮不见了?
- iOS UIWebView 莫名其妙的黑边
- android之socket编程实例(一)
- servlet和web容器之间的关系
- iptables详解 2转载
- 【Linux运维入门】Linux环境安装SonarQube和SonarQube Runner
- Spring mvc+hibernate+freemarker(开源项目)
- jsp 静态引用和动态引用的区别
- FMDB与CoreData
- ubuntu初探5---ubuntu目录结构
- MySql的安装及配置详细指引!
- Codeforces 629C Famil Door and Brackets DP
- 求n的所有素数
- 分布式系统中的算法设计(一) -- 一致性 Hash
- HTTP协议之multipart/form-data请求分析
- android仿淘宝等电商购物车(Expandablelistview)
- lua 插入排序和谢尔排序
- FreeRTOS系列第17篇---FreeRTOS队列