This commit is contained in:
jinyu 2016-12-23 17:20:29 +08:00
parent 9d21efe31f
commit 2adaf6d569
3 changed files with 7 additions and 9 deletions

View File

@ -1558,7 +1558,7 @@ public class WeixinProxy {
*
* @param tplMessage
* 模板消息主体
* @return 发送结果
* @return 发送的消息ID
* @throws WeixinException
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN">
@ -1570,7 +1570,7 @@ public class WeixinProxy {
* @seee com.foxinmy.weixin4j.msg.event.TemplatesendjobfinishMessage
* @see com.foxinmy.weixin4j.mp.api.TmplApi
*/
public ApiResult sendTmplMessage(TemplateMessage tplMessage)
public String sendTmplMessage(TemplateMessage tplMessage)
throws WeixinException {
return tmplApi.sendTmplMessage(tplMessage);
}

View File

@ -147,7 +147,7 @@ public class TmplApi extends MpApi {
*
* @param tplMessage
* 消息对象
* @return 发送结果
* @return 发送的消息ID
* @throws WeixinException
* @see <a
* href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN">模板消息</a>
@ -157,7 +157,7 @@ public class TmplApi extends MpApi {
* @see com.foxinmy.weixin4j.mp.message.TemplateMessage
* @see com.foxinmy.weixin4j.msg.event.TemplatesendjobfinishMessage
*/
public ApiResult sendTmplMessage(TemplateMessage tplMessage)
public String sendTmplMessage(TemplateMessage tplMessage)
throws WeixinException {
Token token = tokenManager.getCache();
String template_send_uri = getRequestUri("template_send_uri");
@ -174,6 +174,6 @@ public class TmplApi extends MpApi {
}
}));
return response.getAsResult();
return response.getAsJson().getString("msgid");
}
}

View File

@ -1,11 +1,9 @@
package com.foxinmy.weixin4j.mp.test;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.weixin.ApiResult;
import com.foxinmy.weixin4j.mp.api.TmplApi;
import com.foxinmy.weixin4j.mp.message.TemplateMessage;
import com.foxinmy.weixin4j.mp.type.IndustryType;
@ -39,7 +37,7 @@ public class TemplateTest extends TokenTest {
TemplateMessage tplMessage = new TemplateMessage("touser",
"template_id", "url");
tplMessage.pushHead("head").pushTail("tail").pushItem("key1", "text1");
ApiResult result = tmplApi.sendTmplMessage(tplMessage);
Assert.assertEquals("0", result.getReturnCode());
String result = tmplApi.sendTmplMessage(tplMessage);
System.out.println(result);
}
}