feature:发送小程序订阅消息支持 miniprogramState 参数

This commit is contained in:
赵丙双 2022-04-18 10:41:17 +08:00
parent e6717c7dbd
commit 9d2177caa0

View File

@ -115,9 +115,10 @@ public class WxaSubscribeMsgApi {
* @param templateId 所需下发的订阅模板id
* @param data
* @param page 示例index?foo=bar
* @param miniprogramState 跳转小程序类型developer为开发版trial为体验版formal为正式版默认为正式版
* @return {ApiResult}
*/
public static ApiResult send(String toUser, String templateId, SubTemplateItem data, String page) {
public static ApiResult send(String toUser, String templateId, SubTemplateItem data, String page, String miniprogramState) {
String accessToken = WxaAccessTokenApi.getAccessTokenStr();
Kv kv = Kv.by("touser", toUser)
.set("template_id", templateId)
@ -125,10 +126,26 @@ public class WxaSubscribeMsgApi {
if (StrKit.notBlank(page)) {
kv.set("page", page);
}
if (StrKit.notBlank(miniprogramState)) {
kv.set("miniprogram_state", miniprogramState);
}
String jsonResult = HttpUtils.post(sendUrl + accessToken, JsonUtils.toJson(kv));
return new ApiResult(jsonResult);
}
/**
* 发送订阅消息
*
* @param toUser 接收者用户 openid
* @param templateId 所需下发的订阅模板id
* @param data
* @param page 示例index?foo=bar
* @return {ApiResult}
*/
public static ApiResult send(String toUser, String templateId, SubTemplateItem data, String page) {
return send(toUser, templateId, data, page, null);
}
public static class SubTemplateItem extends HashMap<String, Item> {
private static final long serialVersionUID = -3728490424738325020L;