码迷,mamicode.com
首页 > 微信 > 详细

java 微信发送客服消息

时间:2015-04-03 13:37:39      阅读:1264      评论:0      收藏:0      [点我收藏+]

标签:微信   java   

public static boolean sendCustomMessage(String accessToken, String jsonMsg){
		logger.info("消息内容:{"+jsonMsg+"}");
		boolean result = false;
		//请求地址
		String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/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+"}");
				if(errorCode == 40001 || errorCode == 42001 ){
					System.out.println("12321");
					new Thread(new TokenThreadNew()).start();
				}
			}
		}
		return result;
	}

java 微信发送客服消息

标签:微信   java   

原文地址:http://blog.csdn.net/u011072139/article/details/44852841

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!