微信多媒体上传图片,创建卡券上传 LOGO

//*****************************************多媒体上传图片 begin***************************************************
WritableResource resource = new FileSystemResource(new File("C:/Users/IBM_ADMIN/Desktop/a.jpg"));
MultiValueMap<String, Object> data = new LinkedMultiValueMap<String,Object>();
data.add("media", resource);
// data.add("type", "image");
// data.add("access_token", "M2brmyjO6xyUb42OZoeJJ0CWJtOXkVG6e1tAtjZG4AtcjG9mb6FCnocpC7uYeAi_WOOzI7IR14fSrvyCLErIvrjdmG2qhl8oHFimFLGg8LM");
// RestTemplate restTemplate = new RestTemplate();
// String result = restTemplate.postForObject("http://file.api.weixin.qq.com/cgi-bin/media/upload", data, String.class);

String tokenString = "M2brmyjO6xyUb42OZoeJJ0CWJtOXkVG6e1tAtjZG4AtcjG9mb6FCnocpC7uYeAi_WOOzI7IR14fSrvyCLErIvrjdmG2qhl8oHFimFLGg8LM";
String urlString = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token="+tokenString+"&type=image";
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.postForObject(urlString, data, String.class);

System.out.println(result);
//****************************************多媒体上传图片 end*****************************************************

 

//*****************************************创建卡券上传 LOGO 接口 begin***************************************************
WritableResource resource = new FileSystemResource(new File("C:/Users/IBM_ADMIN/Desktop/a.jpg"));
MultiValueMap<String, Object> data = new LinkedMultiValueMap<String,Object>();
data.add("buffer", resource);

String tokenString = "M2brmyjO6xyUb42OZoeJJ0CWJtOXkVG6e1tAtjZG4AtcjG9mb6FCnocpC7uYeAi_WOOzI7IR14fSrvyCLErIvrjdmG2qhl8oHFimFLGg8LM";
String urlString = "https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token="+tokenString;
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.postForObject(urlString, data, String.class);

System.out.println(result);
//****************************************创建卡券上传 LOGO 接口 end*****************************************************

你可能感兴趣的:(logo)