关于接收事件以及推送消息相关的java开发
写这个博客,希望能够帮助刚开始进⾏开发的新⼿们(当然也包括我⾃⼰):
在这个地⽅到的AppID、AppSecret、并且设置IP⽩名单(就是你的服务器的ip)。因为本⽂涉及调⽤消息的接⼝,所以启⽤了服务器的配置,注意该选项中的服务器地址⼀定是能够接受服务器xml流并且返回⼀个信息的⽅法。我采⽤的是ssm框架,所以写的地址是⼀个controller的⽅法。令牌是⾃⼰设置的。下⾯上代码
@Controller
@RequestMapping("/weixinCon")
public class WeixinController {
@Resource
private OutBoundService outBoundService;//订单
@Resource
月上柳梢头人约黄昏后
private OrderDetailService orderDetailService;
@RequestMapping(value = "/chat")
lol武器大师出装public void get(HttpServletRequest request, HttpServletResponse response)
throws IOException {
try {
// 获取了扫码的⼈的openID
Map map = parseXml(request);
String openID = (String) ("FromUserName");
String scene_str=(String) ("EventKey");//订单ID
System.out.println(scene_str+"==="+System.currentTimeMillis());
String orderid="";
if(ains("qrscene_")){
orderid=scene_str.substring(8);
}
int order_id=Integer.parseInt(orderid);
// log.info((String) ("EventKey"));建军94周年
// log.info((String) ("Event"));//SCAN
if (((String) ("Event")).equals("SCAN")) {
// 调⽤推送消息接⼝
OutBound ByOpenId(openID);
System.out.println(outBound);
if(outBound==null){
outBound.setIntegral(count);
int r=outBoundService.updateOpenIdAndIntegral(outBound);
System.out.println(r+"===null输出结果");
}else{
outBound.Integral()+count);
int r=outBoundService.updateIntegral(outBound);
System.out.println(r+"===输出结果");
}
什么叫私募基金}
} catch (Exception e1) {
e1.printStackTrace();
}
女士香水排行榜// 加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。String signature = Parameter("signature") == null ? ""
: Parameter("signature");
// 时间戳
String timestamp = Parameter("timestamp") == null ? ""
: Parameter("timestamp");
// 随机数
String nonce = Parameter("nonce") == null ? "" : request
.getParameter("nonce");
// 随机字符串
String echostr = Parameter("echostr") == null ? "" : request
.getParameter("echostr");
PrintWriter out = null;
try {
out = Writer();
// 通过检验signature对请求进⾏校验,若校验成功则原样返回echostr,否则接⼊失败
if (SignUtil.checkSignature(signature, timestamp, nonce)) {
out.write(echostr);
}
} catch (IOException e) {
e.printStackTrace();
} finally {尽的多音字组词
out.close();
out = null;
}
}
加密是必须反馈给服务器的。