1.[代码][Java]代码
微信服务器
*/
公共void doget (httpservletrequestrequest,HttpServletResponse response ) )。
throws ServletException,IOException {
//微信加密签名
string signature=request.getparameter (signature );
//时间戳
string timestamp=request.getparameter (' timestamp );
//随机数
string nonce=request.getparameter (' nonce );
//随机字符串
stringechostr=request.getparameter (echostr );
printwriter out=response.get writer (;
listweixinaccountentities=weixinaccountservice
. getlist (weixinaccountentity.class;
//经过测试,signature对申请中止检查,如果检查胜利,则直接去echostr,表示访问胜利,否则访问失败
weixinaccountentityaccount : weixinaccountentities ({
sign util.check signature (account.getaccounttoken )、signature、
timestamp,nonce ) }{
out.print(Echostr;
}
}
out.close (;
out=null;
}
//*
*解析来自微信服务器的消息
*/
公共void dopost (httpservletrequestrequest,HttpServletResponse response ) )。
throws ServletException,IOException {
//将申请、照应的代码全部设为UTF-8 (防止中文乱码) )。
request.setcharacterencoding (utf-8 );
response.setcharacterencoding (utf-8 );
微信服务微信服务=网络服务(;
//调用周边业务类接受消息、解决消息
stringrespmessage=wechatservice.coreservice (request;
//参照新闻
printwriter out=response.get writer (;
out.print(respmessage;
out.close (;
}
(手机商城