二维码
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
//import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.auth.GetPhoneDTO;
|
||||
import com.czg.account.dto.auth.LoginTokenDTO;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class AcAccountUtil {
|
||||
bodyJson.put("action_name", "QR_SCENE");
|
||||
JSONObject actionInfo = new JSONObject();
|
||||
JSONObject scene = new JSONObject();
|
||||
scene.put("scene_id", userId);
|
||||
scene.put("scene_str", userId.toString());
|
||||
actionInfo.put("scene", scene);
|
||||
bodyJson.put("action_info", actionInfo);
|
||||
|
||||
@@ -102,23 +102,26 @@ public class AcAccountUtil {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String accessToken = "97_Kgg5H4EvOGc67n2GoR7Kqp-NuREOMuzesG0CpbNrx1JhvM6axp9Ub6OoZzBeANuQI3vExR9onbEeBhLdgiMjLjxpiwgDmXOgvZS_rEL5S766QVJQ7p2eggksyuQFPRdAEALVX";
|
||||
// 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_-4x_Mt_x243Ixmcm0kEuO5t7y7RGCdCMXQyIBBi_LCX2B7kdGSZj0XZ4poHC1J4bmMWVdMI1Gengm9phoXWbirwPmTjj2mfmEBoCNe4FeZA6dg3ZLBslvCaOijECHUhAJAVAN";
|
||||
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_SCENE");
|
||||
bodyJson.put("action_name", "QR_STR_SCENE");
|
||||
JSONObject actionInfo = new JSONObject();
|
||||
JSONObject scene = new JSONObject();
|
||||
scene.put("scene_id", 333);
|
||||
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":36434}},"action_name":"QR_SCENE","expire_seconds":"2592000"}, 响应内容: {"errcode":40052,"errmsg":"invalid action name rid: 68f5e3ac-7f703951-6a8908fa"}
|
||||
//{"action_info":{"scene":{"scene_id":36449}},"action_name":"QR_SCENE","expire_seconds":"2592000"}
|
||||
// {"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"}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user