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 31efa4f7c7545d13f1d4cfe6a91cb42aeab95a9f..1ca63f5fd1d1ec8d0d0706c17256a11199eb2b6e 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; + } } 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 f9758c18cf8533a61c6f985bc8c6ae0870abbe18..86421afeb92f06b676737d1039b4c08d42ded3fc 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; @@ -70,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()); @@ -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; } 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 946205cf2eb05eb9f5e849f6453ae07b25050395..ab08c86b19287c0854f48f234f0386642d51b90d 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;