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

java 微信带参数的二维码

时间:2015-04-10 11:30:59      阅读:402      评论:0      收藏:0      [点我收藏+]

标签:微信   二维码   

//获取ticket
public static String getQr(String accessToken, String jsonMsg){
		String result = null;
		String requestUrl = " https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN";
		requestUrl = requestUrl.replace("TOKEN", accessToken);
		JSONObject jsonObject = WeixinUtil.httpRequest(requestUrl, "POST", jsonMsg);
		if(null != jsonObject){
			System.out.println(jsonObject);
			result = jsonObject+"";
		}
		return result;
	}
	//用ticket获取二维码
	public static boolean chageQr(String ticket){
		boolean result = false;
		String requestUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=TICKET";
		requestUrl = requestUrl.replace("TICKET", ticket);
		JSONObject jsonObject = WeixinUtil.httpRequest(requestUrl, "GET", null);
		System.out.println(jsonObject+"");
		if(null != jsonObject){
			System.out.println(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;
	}

java 微信带参数的二维码

标签:微信   二维码   

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

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