zoukankan      html  css  js  c++  java
  • Json化数据-调微信接口

    // 先获取用户openid列表
    List<String> openids = wxPhotoUpload.getUserOpenIdList(access_token);
    TreeMap<String, String> params = new TreeMap<>();
    params.put("access_token", access_token);
    // post 提交的参数
    Map<String, Object> mpnewsParams = new HashMap<>();
    mpnewsParams.put("media_id", messageMediaId);
    TreeMap<String,Object> dataParams = new TreeMap<>();
    dataParams.put("touser", openids);
    dataParams.put("mpnews", mpnewsParams);
    dataParams.put("msgtype", "mpnews");
    dataParams.put("send_ignore_reprint", 0);
    String data = JSON.toJSONString(dataParams);
    String URL = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token="+access_token; // 正式群发接口
    // String URL = "https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token="+access_token; // 阅览群发接口
    String jsonStr = HttpClientUtil.post(URL, data);
    if(jsonStr.indexOf("msg_id") != -1 ){
    jsonStr = jsonStr.replaceAll("[\\]", "");
    net.sf.json.JSONObject resultJSON= net.sf.json.JSONObject.fromObject(jsonStr);
    if (resultJSON != null && resultJSON.get("msg_id") != null) {
    groupWxMessage.setUploadTime(new Date());
    groupWxMessage.setGmtModified(new Date());
    if(groupWxMessage.getStatus() ==1 ){
    groupWxMessage.setStatus(2);
    }
    i = groupWxMessageMapper.updateByPrimaryKeySelective(groupWxMessage);
    }
    }
  • 相关阅读:
    springboot与docker
    Docker入门笔记(Centos7)
    记录VUE-CLI项目创建及初始化相关
    centos下安装mysql5.6
    GitLab权限介绍
    属性文件操作之Properties与ResourceBundle
    Shell入门基础
    JavaScript基础的记录
    Java基本排序算法
    解读闭包,这次从ECMAScript词法环境,执行上下文说起
  • 原文地址:https://www.cnblogs.com/jabez1992/p/9722322.html
Copyright © 2011-2022 走看看