From b0ebd9e7597abf2a092f92a014c499fd2ef76387 Mon Sep 17 00:00:00 2001 From: wuwentao Date: Mon, 6 Feb 2017 15:49:35 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E2=80=9C=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=B7=B2=E6=B7=BB=E5=8A=A0=E8=87=B3=E5=B8=90=E5=8F=B7?= =?UTF-8?q?=E4=B8=8B=E6=89=80=E6=9C=89=E6=A8=A1=E6=9D=BF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E2=80=9DAPI=E4=B8=ADjson=E8=BD=AC=E6=8D=A2=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java index f9758c1..68ee86f 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java @@ -6,6 +6,7 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.alibaba.fastjson.JSONArray; import com.github.sd4324530.fastweixin.api.config.ApiConfig; import com.github.sd4324530.fastweixin.api.entity.Industry; import com.github.sd4324530.fastweixin.api.entity.TemplateMsg; @@ -89,7 +90,7 @@ public class TemplateMsgAPI extends BaseAPI { String url = BASE_API_URL + "cgi-bin/template/get_all_private_template?access_token=#"; BaseResponse r = executeGet(url); String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); - PrivateTemplate[] templates = JSONUtil.toBean(JSONUtil.toJson(JSONUtil.getJSONFromString(resultJson).get("template_list")), PrivateTemplate[].class); + PrivateTemplate[] templates = JSONArray.toJavaObject((JSONArray)JSONUtil.getJSONFromString(resultJson).get("template_list"), PrivateTemplate[].class); return templates; } -- Gitee From cddcb9075c7672c3ed3f42cc2096c209f05cc98a Mon Sep 17 00:00:00 2001 From: wuwentao Date: Mon, 6 Feb 2017 16:20:24 +0800 Subject: [PATCH 2/4] =?UTF-8?q?topcolor=E5=B7=B2=E7=BB=8FDeprecated?= =?UTF-8?q?=E4=BA=86=EF=BC=8C=E5=9C=A8sendTemplateMsg=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=8E=BB=E6=8E=89requireNonNull=20=E7=9A=84=E6=A3=80?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java index 68ee86f..86421af 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java @@ -71,7 +71,7 @@ public class TemplateMsgAPI extends BaseAPI { BeanUtil.requireNonNull(msg.getTouser(), "openid is null"); BeanUtil.requireNonNull(msg.getTemplateId(), "template_id is null"); BeanUtil.requireNonNull(msg.getData(), "data is null"); - BeanUtil.requireNonNull(msg.getTopcolor(), "top color is null"); +// BeanUtil.requireNonNull(msg.getTopcolor(), "top color is null"); // BeanUtil.requireNonNull(msg.getUrl(), "url is null"); String url = BASE_API_URL + "cgi-bin/message/template/send?access_token=#"; BaseResponse r = executePost(url, msg.toJsonString()); -- Gitee From ed611b3ed2c5d9a3035b2ad70b45bc702569faab Mon Sep 17 00:00:00 2001 From: WTW <543199837@qq.com> Date: Thu, 23 Feb 2017 11:21:01 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=E6=9E=84=E9=80=A0=E6=96=B9=E6=B3=95=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=BA=8F=E5=88=97=E5=8C=96=E3=80=81json?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sd4324530/fastweixin/message/req/SendMessageEvent.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/message/req/SendMessageEvent.java b/src/main/java/com/github/sd4324530/fastweixin/message/req/SendMessageEvent.java index 946205c..ab08c86 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/message/req/SendMessageEvent.java +++ b/src/main/java/com/github/sd4324530/fastweixin/message/req/SendMessageEvent.java @@ -11,7 +11,11 @@ public class SendMessageEvent extends BaseEvent{ private Integer sentCount;//发送成功数量 private Integer errorCount;//发送失败数量 - public SendMessageEvent(String msgId, String status, Integer totalCount, Integer filterCount, Integer sentCount, Integer errorCount){ + public SendMessageEvent() { + super(); + } + + public SendMessageEvent(String msgId, String status, Integer totalCount, Integer filterCount, Integer sentCount, Integer errorCount){ super(); this.msgId=msgId; this.status=status; -- Gitee From a04390fd95342eb31f65c6d6b8803906bc23d56a Mon Sep 17 00:00:00 2001 From: WTW <543199837@qq.com> Date: Sat, 25 Mar 2017 15:48:10 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=BE=97?= =?UTF-8?q?=E6=B0=B8=E4=B9=85=E7=B4=A0=E6=9D=90=E7=9A=84=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84api=E3=80=81=E5=8F=AA=E8=8E=B7=E5=8F=96=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E3=80=81=E4=B8=8D=E8=BF=9B=E8=A1=8C=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sd4324530/fastweixin/api/MaterialAPI.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java index 31efa4f..1ca63f5 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java @@ -235,4 +235,20 @@ public class MaterialAPI extends BaseAPI { LOG.error("其他异常", e); } } + + /** + * 获得永久素材的信息、只获取信息、不进行下载 + * @param mediaId + * @return + */ + public DownloadMaterialResponse getMaterial(String mediaId) { + DownloadMaterialResponse materialresponse = null; + String url = BASE_API_URL + "cgi-bin/material/get_material?access_token=#"; + Map param = new HashMap(); + param.put("media_id", mediaId); + BaseResponse r = executePost(url, JSONUtil.toJson(param)); + String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); + materialresponse = JSONUtil.toBean(resultJson, DownloadMaterialResponse.class); + return materialresponse; + } } -- Gitee