zoukankan      html  css  js  c++  java
  • 微信多媒体上传图片,创建卡券上传 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*****************************************************

  • 相关阅读:
    导航属性
    提笔忘字
    JavaScript学习总结(一)——闭包、对象、函数
    CSS3新特性(阴影、动画、渐变)
    图片轮播(也可以通过点击下标播放对应的图片)
    CSS3与页面布局学习总结——多种页面布局
    多种居中方法
    二级菜单
    无间隙轮播图片
    模块和程序处理
  • 原文地址:https://www.cnblogs.com/qq809102690/p/4424088.html
Copyright © 2011-2022 走看看