html52.com
我爱小程序-开发者交流社区

微信调用订阅服务通知,微信服务端数据接收不到,是怎么回事?

实体封装类
public class WeixinTemplate {

    private String touser;
    private String template_id;
    private String page;
    private WeixinTemplateParam templateParamList;

    public String getTouser() {
        return touser;
    }

    public void setTouser(String touser) {
        this.touser = touser;
    }

    public String getTemplate_id() {
        return template_id;
    }

    public void setTemplate_id(String template_id) {
        this.template_id = template_id;
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public WeixinTemplateParam getTemplateParamList() {
        return templateParamList;
    }

    public void setTemplateParamList(WeixinTemplateParam templateParamList) {
        this.templateParamList = templateParamList;
    }
}

public class WeixinTemplateParam {

    private KeyNote number6;
    private KeyNote number5;

    public KeyNote getNumber6() {
        return number6;
    }

    public void setNumber6(KeyNote number6) {
        this.number6 = number6;
    }

    public KeyNote getNumber5() {
        return number5;
    }

    public void setNumber5(KeyNote number5) {
        this.number5 = number5;
    }
}

public class KeyNote {
    private String value;

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}

这是订阅服务模板信息

  详细内容 
    累计积分{{number6.DATA}}
    获得积分{{number5.DATA}}
  


这是我要发送的
 WeixinTemplate template = new WeixinTemplate();
            template.setTemplate_id(notifyTemplateId1);
            template.setTouser(openid);
            template.setPage(notifyPage);
            WeixinTemplateParam weixinTemplateParam = new WeixinTemplateParam();
            KeyNote number6 = new KeyNote();
            number6.setValue("2");
            KeyNote number5 = new KeyNote();
            number5.setValue("22");
            weixinTemplateParam.setNumber6(number6);
            weixinTemplateParam.setNumber5(number5);
            template.setTemplateParamList(weixinTemplateParam);
            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken;
            String byJson = HttpUtil.sendPostRequestByJson(requestUrl, JsonUtils.writeObjectToJson(template, true), "UTF-8");
这是我的util
 /**
 * POST join请求
 *
 * @param url
 * @param json
 * @param charset
 * @return
 */
public static String sendPostRequestByJson(String url, String json, String charset) {
    HttpPost method = new HttpPost(url);
    StringEntity s = new StringEntity(json, charset);
    s.setContentEncoding(charset);
    s.setContentType("application/json");
    method.setEntity(s);
    return executeMethod(method);
}

private static String executeMethod(HttpUriRequest request) {
    String response = null;
    RequestConfig requestConfig = RequestConfig.custom()
            .setConnectTimeout(10000)
            .setSocketTimeout(10000)
            .setConnectionRequestTimeout(10000).build();
    CloseableHttpClient client = HttpClients.custom().setDefaultRequestConfig(requestConfig).build();
    try {
        CloseableHttpResponse httpResponse = client.execute(request);
        if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            HttpEntity httpEntity = httpResponse.getEntity();
            response = EntityUtils.toString(httpEntity, Charset.forName("UTF-8"));//取出应答字符串
        }
    } catch (IOException e) {
        logger.error("请求失败", e);
    }
    return response;
}

报错:
  {"errcode":47003,"errmsg":"argument invalid! hint: [jzHzSA02543938] data.number6.value is emtpy"}

求大神帮忙看下,帮忙解决下问题,谢谢!

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付