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*****************************************************

  • 相关阅读:
    彩色文件夹、彩色文件、图标标记(MultiColorWin)快速操作
    git 国内源
    Mysql 日期格式化 复杂日期区间查询
    项目版本管理Git使用详细教程
    SpringBoot 优雅配置跨域多种方式及Spring Security跨域访问配置的坑
    SpringBoot Spring Security 核心组件 认证流程 用户权限信息获取详细讲解
    SpringBoot包扫描之多模块多包名扫描和同类名扫描冲突解决
    初阶绘图
    变量与档案存取
    结构化程式和自定义函数
  • 原文地址:https://www.cnblogs.com/qq809102690/p/4424088.html
Copyright © 2011-2022 走看看