|
|
@@ -0,0 +1,44 @@
|
|
|
+package com.mrxu.framework.common.xcx.api;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.mrxu.framework.common.weixin.base.NullWxResult;
|
|
|
+import com.mrxu.framework.common.weixin.base.WxHttp;
|
|
|
+import com.mrxu.framework.common.xcx.bean.AddTemplateResponse;
|
|
|
+
|
|
|
+public class TemplateMessageApi {
|
|
|
+
|
|
|
+ // https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.addTemplate.html
|
|
|
+ private static String addTemplate = "https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate";
|
|
|
+
|
|
|
+ //发送模板消息
|
|
|
+ // https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html
|
|
|
+ private static String sendMsg = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send";
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author: xujunwei
|
|
|
+ * @Date: 2022/2/18
|
|
|
+ * tid :模板标题 id,可通过接口获取,也可登录小程序后台查看获取
|
|
|
+ * kidList :开发者自行组合好的模板关键词列表,关键词顺序可以自由搭配(例如 [3,5,4] 或 [4,5,3]),最多支持5个,最少2个关键词组合
|
|
|
+ * sceneDesc : 服务场景描述,15个字以内
|
|
|
+ * @Description:
|
|
|
+ */
|
|
|
+ public static AddTemplateResponse addTemplate(String token,String tid, int[] kidList,String sceneDesc) {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("tid",tid);
|
|
|
+ json.put("kidList",kidList);
|
|
|
+ json.put("sceneDesc",sceneDesc);
|
|
|
+ return WxHttp.post(AddTemplateResponse.class, addTemplate+"?access_token="+token, json);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 参考:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/uniform-message/uniformMessage.send.html
|
|
|
+ * @param token
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static NullWxResult sendMsg(String token, JSONObject json) {
|
|
|
+ return WxHttp.post(NullWxResult.class, sendMsg+"?access_token="+token, json);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|