文章要点描述:
1. 调用微信API获取接口请求凭证信息;
2. 调用微信API并获取小程序码二进制流信息;
3. 使用字节流解析,并转换成图片,随即上传至七牛云;
4. 手动拼接图片的访问URL.
private static final String ACCESS_TOKEN_KEY = "MINI_PROGRAM_ACCESS_TOKEN";
// URL=> 获取接口调用凭证
private static final String GET_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token";
// URL=> 获取小程序码(类型一)
private static final String GET_MINI_PROGRAM_CODE_TYPE_ONE = "https://api.weixin.qq.com/wxa/getwxacode?access_token=";
@Value("${miniapp.appid}")
private String appid;
@Value("${miniapp.secret}")
private String secret;
/**
* @return java.lang.String
* @throws
* @description 获取小程序码
* @params [path]
*/
public String getWxacode(String path) throws IOException {
GetWxaCodeReqDTO wxaCodeReqDTO = new GetWxaCodeReqDTO();
wxaCodeReqDTO.setPath(path);
RBucket<Object> accessTokenBucket = redissonClient.getBucket(ACCESS_TOKEN_KEY);
// 接口请求凭证
String a