@@ -22,6 +22,7 @@ public interface WxMpKefuService { | |||
* <pre> | |||
* 发送客服消息 | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547&token=&lang=zh_CN">发送客服消息</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN | |||
* </pre> | |||
*/ | |||
boolean sendKefuMessage(WxMpKefuMessage message) throws WxErrorException; | |||
@@ -2,11 +2,12 @@ package me.chanjar.weixin.mp.api; | |||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | |||
import me.chanjar.weixin.common.exception.WxErrorException; | |||
import me.chanjar.weixin.mp.bean.*; | |||
import me.chanjar.weixin.mp.bean.result.*; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterial; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialArticleUpdate; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.material.*; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
/** | |||
@@ -20,21 +21,58 @@ import java.io.InputStream; | |||
public interface WxMpMaterialService { | |||
/** | |||
* <pre> | |||
* 新增临时素材 | |||
* | |||
* @param mediaType | |||
* @param file | |||
* 公众号经常有需要用到一些临时性的多媒体素材的场景,例如在使用接口特别是发送消息时,对多媒体文件、多媒体消息的获取和调用等操作,是通过media_id来进行的。 | |||
* 素材管理接口对所有认证的订阅号和服务号开放。通过本接口,公众号可以新增临时素材(即上传临时多媒体文件)。 | |||
* 请注意: | |||
* 1、对于临时素材,每个素材(media_id)会在开发者上传或粉丝发送到微信服务器3天后自动删除(所以用户发送给开发者的素材,若开发者需要,应尽快下载到本地),以节省服务器资源。 | |||
* 2、media_id是可复用的。 | |||
* 3、素材的格式大小等要求与公众平台官网一致。具体是,图片大小不超过2M,支持png/jpeg/jpg/gif格式,语音大小不超过5M,长度不超过60秒,支持mp3/amr格式 | |||
* 4、需使用https调用本接口。 | |||
* 本接口即为原“上传多媒体文件”接口。 | |||
* 注意事项: | |||
* 上传的临时多媒体文件有格式和大小限制,如下: | |||
* 图片(image): 2M,支持PNG\JPEG\JPG\GIF格式 | |||
* 语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式 | |||
* 视频(video):10MB,支持MP4格式 | |||
* 缩略图(thumb):64KB,支持JPG格式 | |||
*媒体文件在后台保存时间为3天,即3天后media_id失效。 | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738726&token=&lang=zh_CN">新增临时素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE | |||
* </pre> | |||
* @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} | |||
* @param file 文件对象 | |||
* @throws WxErrorException | |||
* @see #mediaUpload(String, String, InputStream) | |||
*/ | |||
WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException; | |||
/** | |||
* <pre> | |||
* 新增临时素材 | |||
* 本接口即为原“上传多媒体文件”接口。 | |||
* | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738726&token=&lang=zh_CN">新增临时素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE | |||
* </pre> | |||
* | |||
* @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} | |||
* @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} | |||
* @param inputStream 输入流 | |||
* @throws WxErrorException | |||
* @see #mediaUpload(java.lang.String, java.io.File) | |||
*/ | |||
WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException; | |||
/** | |||
* <pre> | |||
* 获取临时素材 | |||
* 公众号可以使用本接口获取临时素材(即下载临时的多媒体文件)。请注意,视频文件不支持https下载,调用该接口需http协议。 | |||
* 本接口即为原“下载多媒体文件”接口。 | |||
* 根据微信文档,视频文件下载不了,会返回null | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki/9/677a85e3f3849af35de54bb5516c2521.html">获取临时素材</a> | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738727&token=&lang=zh_CN">获取临时素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID | |||
* </pre> | |||
* | |||
* @param media_id | |||
@@ -46,10 +84,12 @@ public interface WxMpMaterialService { | |||
/** | |||
* <pre> | |||
* 上传图文消息内的图片获取URL | |||
* 详情请见:http://mp.weixin.qq.com/wiki/15/40b6865b893947b764e2de8e4a1fb55f.html#.E4.B8.8A.E4.BC.A0.E5.9B.BE.E6.96.87.E6.B6.88.E6.81.AF.E5.86.85.E7.9A.84.E5.9B.BE.E7.89.87.E8.8E.B7.E5.8F.96URL.E3.80.90.E8.AE.A2.E9.98.85.E5.8F.B7.E4.B8.8E.E6.9C.8D.E5.8A.A1.E5.8F.B7.E8.AE.A4.E8.AF.81.E5.90.8E.E5.9D.87.E5.8F.AF.E7.94.A8.E3.80.91 | |||
* 请注意,本接口所上传的图片不占用公众号的素材库中图片数量的5000个的限制。图片仅支持jpg/png格式,大小必须在1MB以下。 | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738729&token=&lang=zh_CN">新增永久素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN | |||
* </pre> | |||
* | |||
* @param file | |||
* @param file 上传的文件对象 | |||
* @return WxMediaImgUploadResult 返回图片url | |||
* @throws WxErrorException | |||
*/ | |||
@@ -57,114 +97,123 @@ public interface WxMpMaterialService { | |||
/** | |||
* <pre> | |||
* 新增临时素材 | |||
* 本接口即为原“上传多媒体文件”接口。 | |||
* | |||
* 上传的多媒体文件有格式和大小限制,如下: | |||
* 图片(image): 1M,支持JPG格式 | |||
* 语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式 | |||
* 视频(video):10MB,支持MP4格式 | |||
* 缩略图(thumb):64KB,支持JPG格式 | |||
* | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki/15/2d353966323806a202cd2deaafe8e557.html">新增临时素材</a> | |||
* </pre> | |||
* | |||
* @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} | |||
* @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} | |||
* @param inputStream 输入流 | |||
* @throws WxErrorException | |||
*/ | |||
WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException; | |||
/** | |||
* <pre> | |||
* 上传非图文永久素材 | |||
* | |||
* 上传的多媒体文件有格式和大小限制,如下: | |||
* 图片(image): 图片大小不超过2M,支持bmp/png/jpeg/jpg/gif格式 | |||
* 语音(voice):语音大小不超过5M,长度不超过60秒,支持mp3/wma/wav/amr格式 | |||
* 视频(video):在上传视频素材时需要POST另一个表单,id为description,包含素材的描述信息,内容格式为JSON | |||
* 缩略图(thumb):文档未说明 | |||
* | |||
* 详情请见: http://mp.weixin.qq.com/wiki/14/7e6c03263063f4813141c3e17dd4350a.html | |||
* 新增非图文永久素材 | |||
* 通过POST表单来调用接口,表单id为media,包含需要上传的素材内容,有filename、filelength、content-type等信息。请注意:图片素材将进入公众平台官网素材管理模块中的默认分组。 | |||
* 新增永久视频素材需特别注意: | |||
* 在上传视频素材时需要POST另一个表单,id为description,包含素材的描述信息,内容格式为JSON,格式如下: | |||
* { "title":VIDEO_TITLE, "introduction":INTRODUCTION } | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738729&token=&lang=zh_CN">新增永久素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE | |||
* | |||
* 除了3天就会失效的临时素材外,开发者有时需要永久保存一些素材,届时就可以通过本接口新增永久素材。 | |||
永久图片素材新增后,将带有URL返回给开发者,开发者可以在腾讯系域名内使用(腾讯系域名外使用,图片将被屏蔽)。 | |||
请注意: | |||
1、新增的永久素材也可以在公众平台官网素材管理模块中看到 | |||
2、永久素材的数量是有上限的,请谨慎新增。图文消息素材和图片素材的上限为5000,其他类型为1000 | |||
3、素材的格式大小等要求与公众平台官网一致。具体是,图片大小不超过2M,支持bmp/png/jpeg/jpg/gif格式,语音大小不超过5M,长度不超过60秒,支持mp3/wma/wav/amr格式 | |||
4、调用该接口需https协议 | |||
* </pre> | |||
* | |||
* @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} | |||
* @param material 上传的素材, 请看{@link me.chanjar.weixin.mp.bean.WxMpMaterial} | |||
* @param material 上传的素材, 请看{@link WxMpMaterial} | |||
*/ | |||
WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material) throws WxErrorException; | |||
/** | |||
* <pre> | |||
* 上传永久图文素材 | |||
* | |||
* 详情请见: http://mp.weixin.qq.com/wiki/14/7e6c03263063f4813141c3e17dd4350a.html | |||
* 新增永久图文素材 | |||
* | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738729&token=&lang=zh_CN">新增永久素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN | |||
* | |||
* 除了3天就会失效的临时素材外,开发者有时需要永久保存一些素材,届时就可以通过本接口新增永久素材。 | |||
永久图片素材新增后,将带有URL返回给开发者,开发者可以在腾讯系域名内使用(腾讯系域名外使用,图片将被屏蔽)。 | |||
请注意: | |||
1、新增的永久素材也可以在公众平台官网素材管理模块中看到 | |||
2、永久素材的数量是有上限的,请谨慎新增。图文消息素材和图片素材的上限为5000,其他类型为1000 | |||
3、素材的格式大小等要求与公众平台官网一致。具体是,图片大小不超过2M,支持bmp/png/jpeg/jpg/gif格式,语音大小不超过5M,长度不超过60秒,支持mp3/wma/wav/amr格式 | |||
4、调用该接口需https协议 | |||
* </pre> | |||
* | |||
* @param news 上传的图文消息, 请看{@link me.chanjar.weixin.mp.bean.WxMpMaterialNews} | |||
* @param news 上传的图文消息, 请看{@link WxMpMaterialNews} | |||
*/ | |||
WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException; | |||
/** | |||
* <pre> | |||
* 下载声音或者图片永久素材 | |||
* 获取声音或者图片永久素材 | |||
* | |||
* 详情请见: http://mp.weixin.qq.com/wiki/4/b3546879f07623cb30df9ca0e420a5d0.html | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738729&token=&lang=zh_CN">获取永久素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN | |||
* </pre> | |||
* | |||
* @param media_id 永久素材的id | |||
* @param mediaId 永久素材的id | |||
*/ | |||
InputStream materialImageOrVoiceDownload(String media_id) throws WxErrorException; | |||
InputStream materialImageOrVoiceDownload(String mediaId) throws WxErrorException; | |||
/** | |||
* <pre> | |||
* 获取视频永久素材的信息和下载地址 | |||
* | |||
* 详情请见: http://mp.weixin.qq.com/wiki/4/b3546879f07623cb30df9ca0e420a5d0.html | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738729&token=&lang=zh_CN">获取永久素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN | |||
* </pre> | |||
* | |||
* @param media_id 永久素材的id | |||
* @param mediaId 永久素材的id | |||
*/ | |||
WxMpMaterialVideoInfoResult materialVideoInfo(String media_id) throws WxErrorException; | |||
WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId) throws WxErrorException; | |||
/** | |||
* <pre> | |||
* 获取图文永久素材的信息 | |||
* | |||
* 详情请见: http://mp.weixin.qq.com/wiki/4/b3546879f07623cb30df9ca0e420a5d0.html | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738729&token=&lang=zh_CN">获取永久素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN | |||
* </pre> | |||
* | |||
* @param media_id 永久素材的id | |||
* @param mediaId 永久素材的id | |||
*/ | |||
WxMpMaterialNews materialNewsInfo(String media_id) throws WxErrorException; | |||
WxMpMaterialNews materialNewsInfo(String mediaId) throws WxErrorException; | |||
/** | |||
* <pre> | |||
* 更新图文永久素材 | |||
* 修改永久图文素材 | |||
* | |||
* 详情请见: http://mp.weixin.qq.com/wiki/4/19a59cba020d506e767360ca1be29450.html | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738732&token=&lang=zh_CN">修改永久图文素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/update_news?access_token=ACCESS_TOKEN | |||
* </pre> | |||
* | |||
* @param wxMpMaterialArticleUpdate 用来更新图文素材的bean, 请看{@link me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate} | |||
* @param wxMpMaterialArticleUpdate 用来更新图文素材的bean, 请看{@link WxMpMaterialArticleUpdate} | |||
*/ | |||
boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate) throws WxErrorException; | |||
/** | |||
* <pre> | |||
* 删除永久素材 | |||
* | |||
* 详情请见: http://mp.weixin.qq.com/wiki/5/e66f61c303db51a6c0f90f46b15af5f5.html | |||
* 在新增了永久素材后,开发者可以根据本接口来删除不再需要的永久素材,节省空间。 | |||
* 请注意: | |||
* 1、请谨慎操作本接口,因为它可以删除公众号在公众平台官网素材管理模块中新建的图文消息、语音、视频等素材(但需要先通过获取素材列表来获知素材的media_id) | |||
* 2、临时素材无法通过本接口删除 | |||
* 3、调用该接口需https协议 | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738731&token=&lang=zh_CN">删除永久素材</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/del_material?access_token=ACCESS_TOKEN | |||
* </pre> | |||
* | |||
* @param media_id 永久素材的id | |||
* @param mediaId 永久素材的id | |||
*/ | |||
boolean materialDelete(String media_id) throws WxErrorException; | |||
boolean materialDelete(String mediaId) throws WxErrorException; | |||
/** | |||
* <pre> | |||
* 获取各类素材总数 | |||
* | |||
* 详情请见: http://mp.weixin.qq.com/wiki/16/8cc64f8c189674b421bee3ed403993b8.html | |||
* 开发者可以根据本接口来获取永久素材的列表,需要时也可保存到本地。 | |||
* 请注意: | |||
* 1.永久素材的总数,也会计算公众平台官网素材管理中的素材 | |||
* 2.图片和图文消息素材(包括单图文和多图文)的总数上限为5000,其他素材的总数上限为1000 | |||
* 3.调用该接口需https协议 | |||
* | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738733&token=&lang=zh_CN">获取素材总数</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/get_materialcount?access_token=ACCESS_TOKEN | |||
* </pre> | |||
*/ | |||
WxMpMaterialCountResult materialCount() throws WxErrorException; | |||
@@ -173,7 +222,8 @@ public interface WxMpMaterialService { | |||
* <pre> | |||
* 分页获取图文素材列表 | |||
* | |||
* 详情请见: http://mp.weixin.qq.com/wiki/12/2108cd7aafff7f388f41f37efa710204.html | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738734&token=&lang=zh_CN">获取素材列表</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN | |||
* </pre> | |||
* | |||
* @param offset 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回 | |||
@@ -185,7 +235,8 @@ public interface WxMpMaterialService { | |||
* <pre> | |||
* 分页获取其他媒体素材列表 | |||
* | |||
* 详情请见: http://mp.weixin.qq.com/wiki/12/2108cd7aafff7f388f41f37efa710204.html | |||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738734&token=&lang=zh_CN">获取素材列表</a> | |||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN | |||
* </pre> | |||
* | |||
* @param type 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} | |||
@@ -10,10 +10,10 @@ import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | |||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||
import me.chanjar.weixin.mp.api.WxMpMaterialService; | |||
import me.chanjar.weixin.mp.api.WxMpService; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterial; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.result.*; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterial; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialArticleUpdate; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.material.*; | |||
import me.chanjar.weixin.mp.util.http.*; | |||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | |||
@@ -37,8 +37,13 @@ public class WxMpMaterialServiceImpl implements WxMpMaterialService { | |||
} | |||
@Override | |||
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException { | |||
return this.mediaUpload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); | |||
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException { | |||
try { | |||
return this.mediaUpload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build()); | |||
} | |||
} | |||
@Override | |||
@@ -1,4 +1,4 @@ | |||
package me.chanjar.weixin.mp.bean.result; | |||
package me.chanjar.weixin.mp.bean.material; | |||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | |||
@@ -9,7 +9,7 @@ import java.io.Serializable; | |||
*/ | |||
public class WxMediaImgUploadResult implements Serializable { | |||
/** | |||
* | |||
* | |||
*/ | |||
private static final long serialVersionUID = 1996392453428768829L; | |||
private String url; |
@@ -1,4 +1,4 @@ | |||
package me.chanjar.weixin.mp.bean; | |||
package me.chanjar.weixin.mp.bean.material; | |||
import java.io.File; | |||
import java.util.HashMap; |
@@ -1,4 +1,4 @@ | |||
package me.chanjar.weixin.mp.bean; | |||
package me.chanjar.weixin.mp.bean.material; | |||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | |||
@@ -7,7 +7,7 @@ import java.io.Serializable; | |||
public class WxMpMaterialArticleUpdate implements Serializable { | |||
/** | |||
* | |||
* | |||
*/ | |||
private static final long serialVersionUID = -7611963949517780270L; | |||
private String mediaId; |
@@ -1,12 +1,11 @@ | |||
package me.chanjar.weixin.mp.bean.result; | |||
package me.chanjar.weixin.mp.bean.material; | |||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||
import org.apache.commons.lang3.builder.ToStringStyle; | |||
import java.io.Serializable; | |||
public class WxMpMaterialCountResult implements Serializable { | |||
/** | |||
* | |||
*/ | |||
private static final long serialVersionUID = -5568772662085874138L; | |||
private int voiceCount; | |||
private int videoCount; | |||
@@ -47,8 +46,7 @@ public class WxMpMaterialCountResult implements Serializable { | |||
@Override | |||
public String toString() { | |||
return "WxMpMaterialCountResult [" + "voiceCount=" + this.voiceCount + ", videoCount=" + this.videoCount | |||
+ ", imageCount=" + this.imageCount + ", newsCount=" + this.newsCount + "]"; | |||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||
} | |||
} | |||
@@ -1,14 +1,13 @@ | |||
package me.chanjar.weixin.mp.bean.result; | |||
package me.chanjar.weixin.mp.bean.material; | |||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||
import org.apache.commons.lang3.builder.ToStringStyle; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
import java.util.List; | |||
public class WxMpMaterialFileBatchGetResult implements Serializable { | |||
/** | |||
* | |||
*/ | |||
private static final long serialVersionUID = -560388368297267884L; | |||
private int totalCount; | |||
private int itemCount; | |||
@@ -40,7 +39,7 @@ public class WxMpMaterialFileBatchGetResult implements Serializable { | |||
@Override | |||
public String toString() { | |||
return "WxMpMaterialFileBatchGetResult [" + "totalCount=" + this.totalCount + ", itemCount=" + this.itemCount + ", items=" + this.items + "]"; | |||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||
} | |||
public static class WxMaterialFileBatchGetNewsItem { | |||
@@ -83,7 +82,7 @@ public class WxMpMaterialFileBatchGetResult implements Serializable { | |||
@Override | |||
public String toString() { | |||
return "WxMaterialFileBatchGetNewsItem [" + "mediaId=" + this.mediaId + ", updateTime=" + this.updateTime + ", name=" + this.name + ", url=" + this.url + "]"; | |||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||
} | |||
} | |||
} |
@@ -1,4 +1,4 @@ | |||
package me.chanjar.weixin.mp.bean; | |||
package me.chanjar.weixin.mp.bean.material; | |||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | |||
import org.apache.commons.lang3.builder.ToStringBuilder; |
@@ -1,17 +1,15 @@ | |||
package me.chanjar.weixin.mp.bean.result; | |||
package me.chanjar.weixin.mp.bean.material; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews; | |||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||
import org.apache.commons.lang3.builder.ToStringStyle; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
import java.util.List; | |||
public class WxMpMaterialNewsBatchGetResult implements Serializable { | |||
/** | |||
* | |||
*/ | |||
private static final long serialVersionUID = -1617952797921001666L; | |||
private int totalCount; | |||
private int itemCount; | |||
private List<WxMaterialNewsBatchGetNewsItem> items; | |||
@@ -42,7 +40,7 @@ public class WxMpMaterialNewsBatchGetResult implements Serializable { | |||
@Override | |||
public String toString() { | |||
return "WxMpMaterialNewsBatchGetResult [" + "totalCount=" + this.totalCount + ", itemCount=" + this.itemCount + ", items=" + this.items + "]"; | |||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||
} | |||
public static class WxMaterialNewsBatchGetNewsItem { | |||
@@ -76,7 +74,7 @@ public class WxMpMaterialNewsBatchGetResult implements Serializable { | |||
@Override | |||
public String toString() { | |||
return "WxMaterialNewsBatchGetNewsItem [" + "mediaId=" + this.mediaId + ", updateTime=" + this.updateTime + ", content=" + this.content + "]"; | |||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||
} | |||
} | |||
} |
@@ -1,4 +1,4 @@ | |||
package me.chanjar.weixin.mp.bean.result; | |||
package me.chanjar.weixin.mp.bean.material; | |||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | |||
@@ -7,7 +7,7 @@ import java.io.Serializable; | |||
public class WxMpMaterialUploadResult implements Serializable { | |||
/** | |||
* | |||
* | |||
*/ | |||
private static final long serialVersionUID = -128818731449449537L; | |||
private String mediaId; |
@@ -1,4 +1,4 @@ | |||
package me.chanjar.weixin.mp.bean.result; | |||
package me.chanjar.weixin.mp.bean.material; | |||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | |||
@@ -7,7 +7,7 @@ import java.io.Serializable; | |||
public class WxMpMaterialVideoInfoResult implements Serializable { | |||
/** | |||
* | |||
* | |||
*/ | |||
private static final long serialVersionUID = 1269131745333792202L; | |||
private String title; |
@@ -5,7 +5,7 @@ import me.chanjar.weixin.common.exception.WxErrorException; | |||
import me.chanjar.weixin.common.util.http.RequestExecutor; | |||
import me.chanjar.weixin.common.util.http.Utf8ResponseHandler; | |||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | |||
import org.apache.http.HttpHost; | |||
import org.apache.http.client.config.RequestConfig; | |||
@@ -5,8 +5,8 @@ import me.chanjar.weixin.common.exception.WxErrorException; | |||
import me.chanjar.weixin.common.util.http.RequestExecutor; | |||
import me.chanjar.weixin.common.util.http.Utf8ResponseHandler; | |||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterial; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialUploadResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterial; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; | |||
import org.apache.http.HttpHost; | |||
import org.apache.http.client.config.RequestConfig; | |||
import org.apache.http.client.methods.CloseableHttpResponse; | |||
@@ -37,7 +37,7 @@ public class MaterialUploadRequestExecutor implements RequestExecutor<WxMpMateri | |||
if (file == null || !file.exists()) { | |||
throw new FileNotFoundException(); | |||
} | |||
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create(); | |||
multipartEntityBuilder | |||
.addBinaryBody("media", file) | |||
@@ -46,7 +46,7 @@ public class MaterialUploadRequestExecutor implements RequestExecutor<WxMpMateri | |||
if (material.getForm() != null) { | |||
multipartEntityBuilder.addTextBody("description", WxGsonBuilder.create().toJson(form)); | |||
} | |||
httpPost.setEntity(multipartEntityBuilder.build()); | |||
httpPost.setHeader("Content-Type", ContentType.MULTIPART_FORM_DATA.toString()); | |||
@@ -5,7 +5,7 @@ import me.chanjar.weixin.common.exception.WxErrorException; | |||
import me.chanjar.weixin.common.util.http.RequestExecutor; | |||
import me.chanjar.weixin.common.util.http.Utf8ResponseHandler; | |||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialVideoInfoResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult; | |||
import org.apache.http.HttpHost; | |||
import org.apache.http.client.config.RequestConfig; | |||
import org.apache.http.client.methods.CloseableHttpResponse; | |||
@@ -4,7 +4,7 @@ import me.chanjar.weixin.common.bean.result.WxError; | |||
import me.chanjar.weixin.common.exception.WxErrorException; | |||
import me.chanjar.weixin.common.util.http.RequestExecutor; | |||
import me.chanjar.weixin.common.util.http.Utf8ResponseHandler; | |||
import me.chanjar.weixin.mp.bean.result.WxMediaImgUploadResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult; | |||
import org.apache.http.HttpEntity; | |||
import org.apache.http.HttpHost; | |||
import org.apache.http.client.config.RequestConfig; | |||
@@ -2,7 +2,7 @@ package me.chanjar.weixin.mp.util.json; | |||
import com.google.gson.*; | |||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||
import me.chanjar.weixin.mp.bean.result.WxMediaImgUploadResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult; | |||
import java.lang.reflect.Type; | |||
@@ -10,19 +10,19 @@ import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage; | |||
import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage; | |||
import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; | |||
import me.chanjar.weixin.mp.bean.WxMpMassVideo; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialArticleUpdate; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; | |||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; | |||
import me.chanjar.weixin.mp.bean.result.WxMediaImgUploadResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult; | |||
import me.chanjar.weixin.mp.bean.result.WxMpCardResult; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialCountResult; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialFileBatchGetResult; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialNewsBatchGetResult; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialUploadResult; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialVideoInfoResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialCountResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialFileBatchGetResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNewsBatchGetResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult; | |||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken; | |||
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; | |||
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult; | |||
@@ -12,8 +12,8 @@ import com.google.gson.JsonElement; | |||
import com.google.gson.JsonObject; | |||
import com.google.gson.JsonSerializationContext; | |||
import com.google.gson.JsonSerializer; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialArticleUpdate; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | |||
import java.lang.reflect.Type; | |||
@@ -10,7 +10,7 @@ package me.chanjar.weixin.mp.util.json; | |||
import com.google.gson.*; | |||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialCountResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialCountResult; | |||
import java.lang.reflect.Type; | |||
@@ -10,7 +10,7 @@ package me.chanjar.weixin.mp.util.json; | |||
import com.google.gson.*; | |||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialFileBatchGetResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialFileBatchGetResult; | |||
import java.lang.reflect.Type; | |||
import java.util.ArrayList; | |||
@@ -10,7 +10,7 @@ package me.chanjar.weixin.mp.util.json; | |||
import com.google.gson.*; | |||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialFileBatchGetResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialFileBatchGetResult; | |||
import java.lang.reflect.Type; | |||
import java.util.Date; | |||
@@ -10,7 +10,7 @@ package me.chanjar.weixin.mp.util.json; | |||
import com.google.gson.*; | |||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | |||
import java.lang.reflect.Type; | |||
@@ -10,7 +10,7 @@ package me.chanjar.weixin.mp.util.json; | |||
import com.google.gson.*; | |||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialNewsBatchGetResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNewsBatchGetResult; | |||
import java.lang.reflect.Type; | |||
import java.util.ArrayList; | |||
@@ -10,8 +10,8 @@ package me.chanjar.weixin.mp.util.json; | |||
import com.google.gson.*; | |||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialNewsBatchGetResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNewsBatchGetResult; | |||
import java.lang.reflect.Type; | |||
import java.util.Date; | |||
@@ -9,7 +9,7 @@ | |||
package me.chanjar.weixin.mp.util.json; | |||
import com.google.gson.*; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | |||
import java.lang.reflect.Type; | |||
@@ -10,7 +10,7 @@ package me.chanjar.weixin.mp.util.json; | |||
import com.google.gson.*; | |||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialUploadResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; | |||
import java.lang.reflect.Type; | |||
@@ -2,7 +2,7 @@ package me.chanjar.weixin.mp.util.json; | |||
import com.google.gson.*; | |||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialVideoInfoResult; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult; | |||
import java.lang.reflect.Type; | |||
@@ -6,10 +6,10 @@ import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | |||
import me.chanjar.weixin.common.exception.WxErrorException; | |||
import me.chanjar.weixin.common.util.fs.FileUtils; | |||
import me.chanjar.weixin.mp.api.ApiTestModule; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterial; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate; | |||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.result.*; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterial; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialArticleUpdate; | |||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | |||
import me.chanjar.weixin.mp.bean.material.*; | |||
import org.testng.annotations.DataProvider; | |||
import org.testng.annotations.Guice; | |||
import org.testng.annotations.Test; | |||