TemplateMsgApiTest.java
1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.jfinal.weixin.sdk.api;
import com.jfinal.kit.PropKit;
/**
* 模板消息测试
* @author L.cm
* email: 596392912@qq.com
* site:http://www.dreamlu.net
* date: 2015年9月9日 下午11:03:48
*/
public class TemplateMsgApiTest {
public static void main(String[] args) {
PropKit.use("a_little_config.txt");
ApiConfig apiConfig = new ApiConfig();
apiConfig.setAppId(PropKit.get("appId"));
apiConfig.setAppSecret(PropKit.get("appSecret"));
ApiConfigKit.putApiConfig(apiConfig);
// 模板消息,发送测试:pass
ApiResult result = TemplateMsgApi.send(TemplateData.New()
// 消息接收者
.setTouser("oCezDv3ZPXdhCJEYFKAnxAvhiRI8")
// 模板id
.setTemplate_id("-nl2DpT-b09Vnod6pGp2VRhj56Lt31dF5S2mtBGz2D8")
.setUrl("http://www.baidu.com")
// 模板参数
.add("first", "支付成功!\n", "#999")
.add("second", "购买年卡成功", "#999")
.add("content", "感谢您的光顾", "#999")
.build());
System.out.println(result);
}
}