zoukankan      html  css  js  c++  java
  • 微信公众开发接入服务器的接口配置信息

    微信官方验证主要参数

            String signature = request.getParameter("signature");
            String echostr = request.getParameter("echostr");
            String timestamp = request.getParameter("timestamp");
            String nonce = request.getParameter("nonce");

    echostr,如果此参数为空:正常处理微信消息即可,反之为验证。

    下面来看一下主要代码:

    		// 微信消息处理流程
    		if (null == echostr || echostr.isEmpty()) {
    			request.setCharacterEncoding("UTF-8");
    			response.setCharacterEncoding("UTF-8");
    			xml = WeChatUtils.readStreamParameter(request.getInputStream());
    			if (null != xml && !xml.isEmpty()) {
    				if (null != db) {
    					result = WeChatUtils.processWechatMag(xml, db.getAttention_reply());
    					response.getWriter().print(result);
    					response.getWriter().flush();
    					response.getWriter().close();
    				} else {
    					result = WeChatUtils.processWechatMag(xml, attention_reply);
    					response.getWriter().print(result);
    					response.getWriter().flush();
    					response.getWriter().close();
    				}
    			} else {
    				response.getWriter().print("error");
    				response.getWriter().flush();
    				response.getWriter().close();
    			}
    
    		}
    		// 微信验证处理流程
    		else {
    			if (null != db) {
    				if (WeChatUtils.checkSignature(signature, timestamp, nonce, db.getWeixin_token())) {
    					response.getWriter().print(echostr);
    					response.getWriter().flush();
    					response.getWriter().close();
    				} else {
    					response.getWriter().print("error");
    					response.getWriter().flush();
    					response.getWriter().close();
    				}
    			} else {
    				response.getWriter().print("error");
    				response.getWriter().flush();
    				response.getWriter().close();
    			}
    		}
    
  • 相关阅读:
    判断字符串是否为空
    NameVirtualHost *:80 has no VirtualHosts
    angular笔记
    Angular *ngIf length
    angular 8 表单带文件上传接口
    angular8 大地老师学习笔记---第十课
    angular8 大地老师学习笔记---第九课
    angular8 大地老师学习笔记---第八课
    angular8 大地老师学习笔记---第六课
    记录一下网上找到的别人写的angualr总结
  • 原文地址:https://www.cnblogs.com/interdrp/p/5805916.html
Copyright © 2011-2022 走看看