请问调用小程序端生成小程序码的接口,返回的二进制数据怎么转换成图片?
* 请问调用小程序端生成小程序码的接口,返回的二进制数据怎么转换成图片?
* 求生成小程序码的demo,谢谢!
9 回复
[@RequestMapping](/user/RequestMapping) (path = "/barq" , method = RequestMethod.GET) public ResponseEntity< byte []> getWXACode( [@RequestParam](/user/RequestParam) ( "id" ) Long id) { String apiUrl = "https://api.weixin.qq.com" ; // 微信请求服务器 // StringBuffer(apiUrl).append("/wxa/getwxacodeunlimit?access_token=").append(weChat.getWeChatToken().getAccessToken()).toString(); String url = new StringBuffer(apiUrl).append( "/wxa/getwxacode?access_token=" ) .append(weChat.getWeChatToken().getAccessToken()).toString(); HttpHeaders httpHeaders = new HttpHeaders(); // 设置请求参数 Map<String, Object> map = new LinkedHashMap<>(); // map.put(Const.WeChat.SCENE, "id="+id ); map.put(Const.WeChat.PATH, "page/index/index?id=" + id); // map.put(Const.WeChat.WIDTH, 430); // map.put(Const.WeChat.AUTO_COLOR, true); HttpEntity<Map<String, Object>> entity = new HttpEntity<>(map, httpHeaders); return restTemplate.exchange(url, HttpMethod.POST, entity, byte []. class ); } |