mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🎨 #3078 【公众号】模板消息获得模板ID的接口增加选用类目模板的关键词的参数
This commit is contained in:
parent
753497579c
commit
a054560087
@ -66,6 +66,21 @@ public interface WxMpTemplateMsgService {
|
|||||||
*/
|
*/
|
||||||
String addTemplate(String shortTemplateId) throws WxErrorException;
|
String addTemplate(String shortTemplateId) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 获得模板ID
|
||||||
|
* 从类目模板库选择模板到帐号后台,获得模板ID的过程可在MP中完成
|
||||||
|
* 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
|
||||||
|
* 接口地址格式:https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=ACCESS_TOKEN
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param shortTemplateId 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式,对于类目模板,为纯数字ID
|
||||||
|
* @param keywordNameList 选用的类目模板的关键词,按顺序传入,如果为空,或者关键词不在模板库中,会返回40246错误码
|
||||||
|
* @return templateId 模板Id
|
||||||
|
* @throws WxErrorException .
|
||||||
|
*/
|
||||||
|
String addTemplate(String shortTemplateId, List<String> keywordNameList) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 获取模板列表
|
* 获取模板列表
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.chanjar.weixin.mp.api.impl;
|
package me.chanjar.weixin.mp.api.impl;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.chanjar.weixin.common.api.WxConsts;
|
import me.chanjar.weixin.common.api.WxConsts;
|
||||||
@ -68,6 +69,21 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
|
|||||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP));
|
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String addTemplate(String shortTemplateId, List<String> keywordNameList) throws WxErrorException {
|
||||||
|
JsonObject jsonObject = new JsonObject();
|
||||||
|
Gson gson = new Gson();
|
||||||
|
jsonObject.addProperty("template_id_short", shortTemplateId);
|
||||||
|
jsonObject.addProperty("keyword_name_list",gson.toJson(keywordNameList));
|
||||||
|
String responseContent = this.wxMpService.post(TEMPLATE_API_ADD_TEMPLATE, jsonObject.toString());
|
||||||
|
final JsonObject result = GsonParser.parse(responseContent);
|
||||||
|
if (result.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||||
|
return result.get("template_id").getAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<WxMpTemplate> getAllPrivateTemplate() throws WxErrorException {
|
public List<WxMpTemplate> getAllPrivateTemplate() throws WxErrorException {
|
||||||
return WxMpTemplate.fromJson(this.wxMpService.get(TEMPLATE_GET_ALL_PRIVATE_TEMPLATE, null));
|
return WxMpTemplate.fromJson(this.wxMpService.get(TEMPLATE_GET_ALL_PRIVATE_TEMPLATE, null));
|
||||||
|
Loading…
Reference in New Issue
Block a user