JAVA微信二次开发

Wesley13
• 阅读 513

大家首先自己有条件的,自己注册一个微信公众账号
1.一个微信公众账号(供自己测试使用)
2.一个百度开发账号
3.myeclipse开发工具 
4.需要熟悉jeecg开发
5.微信开发代码如下

标签: JEECG  MiniDao

代码片段(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 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();

    }

}

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Jacquelyn38 Jacquelyn38
2年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
梦
3年前
微信小程序new Date()转换时间异常问题
微信小程序苹果手机页面上显示时间异常,安卓机正常问题image(https://imghelloworld.osscnbeijing.aliyuncs.com/imgs/b691e1230e2f15efbd81fe11ef734d4f.png)错误代码vardate'2021030617:00:00'vardateT
Easter79 Easter79
2年前
thinkcmf+jsapi 实现微信支付
首先从小程序端接收订单号、金额等参数,然后后台进行统一下单,把微信支付的订单号返回,在把订单号发送给前台,前台拉起支付,返回参数后更改支付状态。。。回调publicfunctionnotify(){$wechatDb::name('wechat')where('status',1)find();
Wesley13 Wesley13
2年前
PHP微信小程序支付——签名错误
!(https://static.oschina.net/uploads/space/2018/0509/141657_Tqix_3477605.png)先分清几个概念:微信公众平台、微信开放平台、微信商户平台1.微信公众平台、微信开放平台、微信商户平台是三个不同的平台2.微信公众平台:用于公众号、小程序等等的设置平台,包括APPID、APP
Easter79 Easter79
2年前
Taro小程序自定义顶部导航栏
微信自带的顶部导航栏是无法支持自定义icon和增加元素的,在开发小程序的时候自带的根本满足不了需求,分享一个封装好的组件,支持自定义icon、扩展dom,适配安卓、ios、h5,全面屏。我用的是京东的Taro多端编译框架写的小程序,原生的也可以适用,用到的微信/taro的api做调整就行,实现效果如下。!在这里插入图片描述(https://i
Wesley13 Wesley13
2年前
h5 接入微信支付
我们公司,现在用ping做h5接入,用的是h5"壹收款"准备:如果公司,现在还没有公众号的话,支付宝。可以把这些工作,给ping来做这些事情 1.注册微信公众号,开通支付功能。2.注册ping (如果是自己开开通的微信支付,要填写相关信息)3.微信设置网页授权获取用户基本信
Wesley13 Wesley13
2年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Wesley13 Wesley13
2年前
C#开发——网站应用微信登录开发
1\.在微信开放平台注册开发者账号,并有一个审核已通过的网站应用,并获得相对应的AppID和AppSecret,申请通过登陆后,方可开始接入流程。2.微信OAuth2.0授权登录目前支持authorization\_code模式,适用于拥有server端的应用授权。该模式整体流程为:1.第三方发起微信授权登录请求,微信用户允许授权第三方应
Wesley13 Wesley13
2年前
Java微信公众平台开发
转自:http://www.cuiyongzhi.com/post/63.html之前发过一个【微信开发】系列性的文章,也引来了不少朋友观看和点评交流,可能我在写文章时有所疏忽,对部分文件给出的不是很完全所以导致部分同学在有些地方做开发的时候遇到了一些阻力,收到这些朋友同学们的咨询反馈之后我也做了一些反思和总结,其中一部分同学说少了GlobalConst