知识点
相关文章
更多最近更新
更多JAVA微信二次开发
2019-03-02 00:09|来源: 网路
大家首先自己有条件的,自己注册一个微信公众账号
1.一个微信公众账号(供自己测试使用)
2.一个百度开发账号
3.myeclipse开发工具
4.需要熟悉jeecg开发
5.微信开发代码如下
1.一个微信公众账号(供自己测试使用)
2.一个百度开发账号
3.myeclipse开发工具
4.需要熟悉jeecg开发
5.微信开发代码如下
代码片段(1)[全屏查看所有代码]
1. [代码][Java]代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
packageweixin.guanjia.core.controller;
importjava.io.IOException;
importjava.io.PrintWriter;
importjava.util.List;
importjavax.servlet.ServletException;
importjavax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
importorg.springframework.beans.factory.annotation.Autowired;
importweixin.guanjia.account.entity.WeixinAccountEntity;
importweixin.guanjia.account.service.WeixinAccountServiceI;
importweixin.guanjia.account.service.impl.WeixinAccountServiceImpl;
importweixin.guanjia.core.service.impl.WechatService;
importweixin.guanjia.core.util.SignUtil;
/**
* 核心请求处理类
*
*
@author liufeng
* @date 2013-05-18
*/
publicclassWeixinServletextendsHttpServlet {
privatestaticfinallongserialVersionUID = 4440739483644821986L;
@Autowired
privateWeixinAccountServiceI weixinAccountService;
@Override
publicvoidinit()throwsServletException {
weixinAccountService =newWeixinAccountServiceImpl();
}
/**
* 确认请求来自微信服务器
*/
publicvoiddoGet(HttpServletRequest request, HttpServletResponse response)
throwsServletException, IOException {
// 微信加密签名
String signature = request.getParameter("signature");
// 时间戳
String timestamp = request.getParameter("timestamp");
// 随机数
String nonce = request.getParameter("nonce");
// 随机字符串
String echostr = request.getParameter("echostr");
PrintWriter out = response.getWriter();
List<WeixinAccountEntity> weixinAccountEntities = weixinAccountService
.getList(WeixinAccountEntity.class);
// 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败
for(WeixinAccountEntity account : weixinAccountEntities) {
if(SignUtil.checkSignature(account.getAccounttoken(), signature,
timestamp, nonce)) {
out.print(echostr);
}
}
out.close();
out =null;
}
/**
* 处理微信服务器发来的消息
*/
publicvoiddoPost(HttpServletRequest request, HttpServletResponse response)
throwsServletException, IOException {
// 将请求、响应的编码均设置为UTF-8(防止中文乱码)
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
WechatService wechatService =newWechatService();
// 调用核心业务类接收消息、处理消息
String respMessage = wechatService.coreService(request);
// 响应消息
PrintWriter out = response.getWriter();
out.print(respMessage);
out.close();
}
}
|
转自:http://my.oschina.net/u/1157906/blog/305547
相关问答
更多-
能用java做微信二次开发吗[2021-07-03]
微信开发者模式 是提供给交互的一种方式,交互的数据是微信指定格式的XML,至于你怎么处理这个xml,就看你的选择了,理论上任何一个程序设计语言都可以直接或间接操作xml,所以那个用的属性 就用哪个呗 -
一般架构都可以,考虑成本啥的,用MySQL可取。还要考虑开发者对所使用框架爱的熟悉度。综合考虑,方为良策。
-
二次开发 JAVA 怎么写接口[2022-05-04]
这个倒是很少使用java你可以尝试使用 JA 选择java的代码 看看 查看原帖>> 希望采纳 -
开通微信公众号要多少钱?微信二次开发费用多少?[2023-07-18]
开通微信公众号年费300.二次开发费用没家公司就不一样了 -
像摇一摇微信上墙这样的功能,微信公众号二次开发商找哪个做相对好点?[2024-04-01]
这些都是现成的微信营销插件,基本都不用开发,找第三方平台,直接拉过来用就行。 难的是你的公众号内容搭建和运营。 -
微信公众号二次开发[2022-04-12]
微信公众平台统计好友分享次数方法如下: 1、打开微信公众平台,登陆微信公众账号; 2、点击数据统计-图文分析-图文转发,即可查看图文页及原文页阅读人数和次数。 其中分享转发人数为转发或分享至朋友、朋友圈、微博的用户数(不包括重复转发),包括非粉丝分享或转发。 分享转发次数为转发或分享至朋友、朋友圈、微博的总次数,包括非粉丝的分享或转发。 -
微信公众号二次开发怎么弄啊?[2022-01-03]
找第三方开发商像小猪那样的弄,因为有啥接口,你搞不到。 -
微网站、微互动、微场景微应用等功能的,微信公众平台二次开发源码哪有好用的?[2022-11-19]
二次开发多费事 有现成的 而且开发都不愿意二次开发 -
微信公众平台二次开发与微官网的区别[2023-08-09]
微官网其实就是属于二次开发,因为官方是没有这个功能的,是通过第三方开发来实现的,二次开发有很多,微官网只是其一,也是常见功能,就像PC时代的官网一样,现在微信时代就叫微官网,除此之外还有微餐饮、微房产、微酒店、微汽车、微物业等等多种垂直行业的开发。 -
微信公众平台二次开发源码哪有好的?[2022-01-19]
好多技术员就靠这个吃饭呢。。小猪cms的挺好哒。