diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java index 3405aaab7..960ea865a 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java @@ -36,6 +36,7 @@ public class ApacheSimplePostRequestExecutor extends SimplePostRequestExecutor * Service没有实现某个API的时候,可以用这个, diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java index 6899e708a..38ce9cc4a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java @@ -16,6 +16,7 @@ import me.chanjar.weixin.common.util.crypto.SHA1; import me.chanjar.weixin.common.util.http.*; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpHost; import org.apache.http.client.config.RequestConfig; @@ -206,6 +207,11 @@ public class WxMaServiceImpl implements WxMaService, RequestHttpBinary Wang @@ -26,16 +23,14 @@ public class WxMaSubscribeServiceImpl implements WxMaSubscribeService { @Override public WxMaTemplateLibraryListResult getPubTemplateTitleList(Integer[] ids, int start, int limit) throws WxErrorException { - ImmutableMap params = ImmutableMap.of("ids", StringUtils.join(ids, ","), - "start", start, "limit", limit); - String responseText = this.wxMaService.post(GET_PUB_TEMPLATE_TITLE_LIST_URL, WxGsonBuilder.create().toJson(params)); - return WxMaTemplateLibraryListResult.fromJson(responseText); + return WxMaTemplateLibraryListResult.fromJson(this.wxMaService.post(GET_PUB_TEMPLATE_TITLE_LIST_URL, + ImmutableMap.of("ids", StringUtils.join(ids, ","), + "start", start, "limit", limit))); } @Override public List getPubTemplateKeyWordsById(String id) throws WxErrorException { - String responseText = this.wxMaService.post(GET_PUB_TEMPLATE_KEY_WORDS_BY_ID_URL, - WxGsonBuilder.create().toJson(ImmutableMap.of("tid", id))); + String responseText = this.wxMaService.post(GET_PUB_TEMPLATE_KEY_WORDS_BY_ID_URL, ImmutableMap.of("tid", id)); return WxMaGsonBuilder.create().fromJson(new JsonParser().parse(responseText).getAsJsonObject() .getAsJsonArray("data"), new TypeToken>() { }.getType()); @@ -43,9 +38,9 @@ public class WxMaSubscribeServiceImpl implements WxMaSubscribeService { @Override public String addTemplate(String id, List keywordIdList, String sceneDesc) throws WxErrorException { - String responseText = this.wxMaService.post(TEMPLATE_ADD_URL, WxGsonBuilder.create().toJson(ImmutableMap.of("tid", id, + String responseText = this.wxMaService.post(TEMPLATE_ADD_URL, ImmutableMap.of("tid", id, "kidList", keywordIdList.toArray(), - "sceneDesc", sceneDesc))); + "sceneDesc", sceneDesc)); return new JsonParser().parse(responseText).getAsJsonObject().get("priTmplId").getAsString(); } @@ -59,8 +54,7 @@ public class WxMaSubscribeServiceImpl implements WxMaSubscribeService { @Override public boolean delTemplate(String templateId) throws WxErrorException { - Map params = ImmutableMap.of("priTmplId", templateId); - this.wxMaService.post(TEMPLATE_DEL_URL, WxGsonBuilder.create().toJson(params)); + this.wxMaService.post(TEMPLATE_DEL_URL, ImmutableMap.of("priTmplId", templateId)); return true; } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImplTest.java index 706a13dba..5846743cd 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImplTest.java @@ -38,7 +38,7 @@ public class WxMaSubscribeServiceImplTest { @Test public void testAddTemplate() throws WxErrorException { - final String templateId = this.wxService.getSubscribeService().addTemplate("1", Lists.newArrayList(1), ""); + final String templateId = this.wxService.getSubscribeService().addTemplate("1", Lists.newArrayList(1), "hhaa"); System.out.println(templateId); }