This commit is contained in:
parent
2c00b8214f
commit
b024f2b627
|
|
@ -85,7 +85,7 @@ public class AcAccountUtil {
|
|||
|
||||
|
||||
public String getAccessToken() {
|
||||
String accessToken = redisService.get("wx:ac:AccessToken").toString();
|
||||
String accessToken = Convert.toStr(redisService.get("wx:ac:AccessToken"));
|
||||
if (StrUtil.isNotEmpty(accessToken)) {
|
||||
return accessToken;
|
||||
}
|
||||
|
|
@ -106,28 +106,22 @@ public class AcAccountUtil {
|
|||
public static void main(String[] args) {
|
||||
// String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", "wx1fb600d0f5ea6279", "b4c0534c9b5e6c84a7fe5c2078dff876"));
|
||||
// System.out.println(resp);
|
||||
String accessToken = "97_HZVThQrtvOiCZGrr23ZHN0cVpHBJHc18RSFHU6dvkQDMAme4GsG0NU-Dax1HP5Wx-aGa1l35KaqiMVv61TCj0Qk8DK1LC6kQ8uKLDfgRYVJjX3QjcelmIjp4PCkERBeABAUHR";
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
//二维码有效时间(秒),最大2592000,仅临时二维码需要
|
||||
bodyJson.put("expire_seconds", "2592000");
|
||||
//二维码类型:QR_SCENE(临时整型)/QR_STR_SCENE(临时字符串)/QR_LIMIT_SCENE(永久整型)/QR_LIMIT_STR_SCENE(永久字符串)
|
||||
bodyJson.put("action_name", "QR_STR_SCENE");
|
||||
JSONObject actionInfo = new JSONObject();
|
||||
JSONObject scene = new JSONObject();
|
||||
scene.put("scene_str", "43525423");
|
||||
actionInfo.put("scene", scene);
|
||||
bodyJson.put("action_info", actionInfo);
|
||||
System.out.println(bodyJson);
|
||||
// String accessToken = "97_HZVThQrtvOiCZGrr23ZHN0cVpHBJHc18RSFHU6dvkQDMAme4GsG0NU-Dax1HP5Wx-aGa1l35KaqiMVv61TCj0Qk8DK1LC6kQ8uKLDfgRYVJjX3QjcelmIjp4PCkERBeABAUHR";
|
||||
// JSONObject bodyJson = new JSONObject();
|
||||
// //二维码有效时间(秒),最大2592000,仅临时二维码需要
|
||||
// bodyJson.put("expire_seconds", "2592000");
|
||||
// //二维码类型:QR_SCENE(临时整型)/QR_STR_SCENE(临时字符串)/QR_LIMIT_SCENE(永久整型)/QR_LIMIT_STR_SCENE(永久字符串)
|
||||
// bodyJson.put("action_name", "QR_STR_SCENE");
|
||||
// JSONObject actionInfo = new JSONObject();
|
||||
// JSONObject scene = new JSONObject();
|
||||
// scene.put("scene_str", "43525423");
|
||||
// actionInfo.put("scene", scene);
|
||||
// bodyJson.put("action_info", actionInfo);
|
||||
// System.out.println(bodyJson);
|
||||
//创建临时二维码失败,发送参数: {"action_info":{"scene":{"scene_id":36449}},"action_name":"QR_SCENE","expire_seconds":"2592000"}, 响应内容: {"errcode":40052,"errmsg":"invalid action name rid: 68f5fa37-20fb3162-0f87b4f2"}
|
||||
//创建临时二维码失败,发送参数: {"action_info":{"scene":{"scene_id":36449}},"action_name":"QR_SCENE","expire_seconds":"2592000"}, 响应内容: {"errcode":40052,"errmsg":"invalid action name rid: 68f5f970-2a84749c-78e4d78f"}
|
||||
String resps = HttpUtil.post(StrUtil.format("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={}", accessToken), JSONObject.toJSONString(bodyJson));
|
||||
JSONObject respInfos = JSONObject.parseObject(resps);
|
||||
System.out.println(respInfos);
|
||||
// {"action_info":{"scene":{"scene_id":333}},"action_name":"QR_SCENE","expire_seconds":"2592000"}
|
||||
// {"ticket":"gQEZ8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUFVfTnM2MXhmbUoxYTM3dGhGMXIAAgSD_vVoAwQAjScA","expire_seconds":2592000,"url":"http://weixin.qq.com/q/02PU_Ns61xfmJ1a37thF1r"}
|
||||
// String resps = HttpUtil.post(StrUtil.format("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={}", accessToken), JSONObject.toJSONString(bodyJson));
|
||||
// JSONObject respInfos = JSONObject.parseObject(resps);
|
||||
// System.out.println(respInfos);
|
||||
}
|
||||
|
||||
//创建临时二维码失败,发送参数:url:
|
||||
// https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=97_HZVThQrtvOiCZGrr23ZHN0cVpHBJHc18RSFHU6dvkQDMAme4GsG0NU-Dax1HP5Wx-aGa1l35KaqiMVv61TCj0Qk8DK1LC6kQ8uKLDfgRYVJjX3QjcelmIjp4PCkERBeABAUHR,
|
||||
// {"action_info":{"scene":{"scene_str":"10839"}},"action_name":"QR_STR_SCENE","expire_seconds":"2592000"}, 响应内容: {"errcode":40052,"errmsg":"invalid action name rid: 68f60aaf-4dcdbd3c-689c5d95"}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue