String access_token = this.getAccessTokenString();
//封装参数
Map<String, Object> parMap = new HashMap<String, Object>();
parMap.put("medicalOrgCode",medicalOrgCode);
parMap.put("departmentCode",departmentCode);
Gson gson = new Gson();
String scene = gson.toJson(parMap);//带参
if(width==null||width==0){
width = 430;//默认
}
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+access_token;
Map<String,Object> param = new HashMap<>();
param.put("scene", parMap);
param.put("page", "pages/index/index");
param.put("width", width);
param.put("auto_color", false);
Map<String,Object> line_color1 = new HashMap<>();
line_color1.put("r", 0);
line_color1.put("g", 0);
line_color1.put("b", 0);
param.put("line_color", line_color);
System.out.println("调用生成微信URL接口传参:" + param);
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
HttpEntity requestEntity = new HttpEntity(param, headers);
RestTemplate rest = new RestTemplate();
ResponseEntity<byte[]> entity = rest.exchange(url, HttpMethod.POST, requestEntity, byte[].class, new Object[0]);
System.out.println("调用小程序生成微信永久小程序码URL接口返回结果:" + entity.getBody());
byte[] result = entity.getBody();
System.out.println(Base64.encodeBase64String(result));
InputStream instreams = new ByteArrayInputStream(result);
String uploadSysUrl = "F:\\upload"+"/";
saveToImgByInputStream(instreams, uploadSysUrl, id+".jpg"); //保存图片到本地(代码没问题)
String resUrl = ossService.uploadObject(instreams, "wxaqrcode/",
id, FileUtils.getFileExt(".jpg")); //上传到阿里云 (代码没问题)
求解决
appid和page(你的【页面路径】是指这个吧?)没啥问题,
流程在postman上可以正常显示出二维码(小程序码),但是在java代码中却不知如何将此二维码保存于本地硬盘上,直接将返回值打印出来是乱码,就好强记事本打开一个图片一样,现在就是想把这些乱码文本转成可以看到的图片。用常规的FileOutputStream保存出来的图片文件会打不开
检查参数 appid 和页面路径
请问解决了吗,我也遇到了
遇到同样问题,请问楼主是怎么解决的?感谢
你好!!请问这个怎么解决的啊