微信 模板消息的使用

来源:互联网 发布:linux search file 编辑:程序博客网 时间:2024/06/03 06:35
public static boolean sendTemplateMessage(String accessToken, String jsonMsg){logger.info("消息内容:{"+jsonMsg+"}");boolean result = false;//请求地址String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN";requestUrl = requestUrl.replace("ACCESS_TOKEN", accessToken);//发送模板消息JSONObject jsonObject = WeixinUtil.httpRequest(requestUrl, "POST", jsonMsg);if(null != jsonObject){int errorCode = jsonObject.getInt("errcode");String errorMsg = jsonObject.getString("errmsg");if(0 == errorCode){result = true;logger.info("模板消息发送成功errorCode:{"+errorCode+"},errmsg:{"+errorMsg+"}");System.out.println("模板消息发送成功errorCode:{"+errorCode+"},errmsg:{"+errorMsg+"}");}else{logger.info("模板消息发送失败errorCode:{"+errorCode+"},errmsg:{"+errorMsg+"}");System.out.println("模板消息发送失败errorCode:{"+errorCode+"},errmsg:{"+errorMsg+"}");}}return result;}

1 0
原创粉丝点击