|
|
@ -113,28 +113,24 @@ public class WeChatQrcodeUtils { |
|
|
|
object.put("action_name" , "QR_STR_SCENE"); |
|
|
|
object.put("action_name" , "QR_STR_SCENE"); |
|
|
|
object.put("expire_seconds" , 2592000); |
|
|
|
object.put("expire_seconds" , 2592000); |
|
|
|
object.put("action_info" , objectActionInfo); |
|
|
|
object.put("action_info" , objectActionInfo); |
|
|
|
|
|
|
|
return HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + getWxToken(), object); |
|
|
|
if (redisUtil.get("WxToken") == null) { |
|
|
|
|
|
|
|
getWxToken(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + redisUtil.get("WxToken"), object); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取微信Token存入redis
|
|
|
|
// 获取微信Token存入redis
|
|
|
|
public void getWxToken() { |
|
|
|
public String getWxToken() { |
|
|
|
|
|
|
|
Object token = redisUtil.get("WxToken"); |
|
|
|
|
|
|
|
if (null != token) { |
|
|
|
|
|
|
|
return token.toString(); |
|
|
|
|
|
|
|
}; |
|
|
|
// 获取access_token
|
|
|
|
// 获取access_token
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("appid", CommonSysConst.getSysConfig().getWxH5AppId()); |
|
|
|
params.put("appid", CommonSysConst.getSysConfig().getWxH5AppId()); |
|
|
|
params.put("secret", CommonSysConst.getSysConfig().getWxH5AppSecret()); |
|
|
|
params.put("secret", CommonSysConst.getSysConfig().getWxH5AppSecret()); |
|
|
|
params.put("grant_type", "client_credential"); |
|
|
|
params.put("grant_type", "client_credential"); |
|
|
|
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); |
|
|
|
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); |
|
|
|
|
|
|
|
|
|
|
|
if (accessTokenObject != null && accessTokenObject.getString("access_token") != null) { |
|
|
|
|
|
|
|
redisUtil.set("WxToken" , accessTokenObject.getString("access_token") , 7000); |
|
|
|
redisUtil.set("WxToken" , accessTokenObject.getString("access_token") , 7000); |
|
|
|
} |
|
|
|
return accessTokenObject.getString("access_token"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|