1 package com.foxinmy.weixin4j.wxa.api;
2
3 import java.util.Map;
4 import java.util.Properties;
5
6 import com.foxinmy.weixin4j.exception.WeixinException;
7 import com.foxinmy.weixin4j.token.TokenManager;
8
9
10
11
12
13
14
15 public class TemplateMessageApi extends TokenManagerApi {
16
17 public TemplateMessageApi(TokenManager tokenManager) {
18 this(tokenManager, null);
19 }
20
21 public TemplateMessageApi(TokenManager tokenManager, Properties properties) {
22 super(tokenManager, properties);
23 }
24
25
26
27
28
29
30
31
32
33
34
35
36
37 public void sendTemplateMessage(
38 final String toUser,
39 final String templateId,
40 final String page,
41 final String formId,
42 final Map<String, String> data,
43 final String emphasisKeyword
44 ) throws WeixinException {
45 final TemplateMessageParameter message = new TemplateMessageParameter(
46 toUser, templateId, page, formId, data, emphasisKeyword
47 );
48 final WxaApiResult r = this.post(
49 "wxopen_template_message_send",
50 message,
51 WxaApiResult.TYPE_REFERENCE
52 );
53 r.checkErrCode();
54 }
55
56 }