//获取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 微信带参数的二维码