🎨 【公众号】删除已下线的新增删除永久图文素材的接口
Some checks failed
Publish to Maven Central / build-and-publish (push) Has been cancelled

This commit is contained in:
benben 2025-07-12 08:59:11 +00:00 committed by Binary Wang
parent 696ce8621e
commit d4cf48d059
3 changed files with 0 additions and 69 deletions

View File

@ -146,30 +146,6 @@ public interface WxMpMaterialService {
*/
WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material) throws WxErrorException;
/**
* <pre>
* 新增永久图文素材
*
* 详情请见: <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 WxMpMaterialNews}
* @return the wx mp material upload result
* @throws WxErrorException the wx error exception
* @deprecated 关于永久图文素材相关接口下线的公告 : https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&announce_id=11644831863qFQSh&version=&token=2085564289&lang=zh_CN
*/
@Deprecated
WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException;
/**
* <pre>
* 获取声音或者图片永久素材
@ -212,22 +188,6 @@ public interface WxMpMaterialService {
*/
WxMpMaterialNews materialNewsInfo(String mediaId) throws WxErrorException;
/**
* <pre>
* 修改永久图文素材
*
* 详情请见: <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 WxMpMaterialArticleUpdate}
* @return the boolean
* @throws WxErrorException the wx error exception
* @deprecated 关于永久图文素材相关接口下线的公告 : https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&announce_id=11644831863qFQSh&version=&token=2085564289&lang=zh_CN
*/
@Deprecated
boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate) throws WxErrorException;
/**
* <pre>
* 删除永久素材

View File

@ -83,15 +83,6 @@ public class WxMpMaterialServiceImpl implements WxMpMaterialService {
return this.wxMpService.execute(MaterialUploadRequestExecutor.create(this.wxMpService.getRequestHttp()), url, material);
}
@Override
public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException {
if (news == null || news.isEmpty()) {
throw new IllegalArgumentException("news is empty!");
}
String responseContent = this.wxMpService.post(NEWS_ADD_URL, news.toJson());
return WxMpMaterialUploadResult.fromJson(responseContent);
}
@Override
public InputStream materialImageOrVoiceDownload(String mediaId) throws WxErrorException {
return this.wxMpService.execute(MaterialVoiceAndImageDownloadRequestExecutor
@ -111,17 +102,6 @@ public class WxMpMaterialServiceImpl implements WxMpMaterialService {
MATERIAL_GET_URL, mediaId);
}
@Override
public boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate) throws WxErrorException {
String responseText = this.wxMpService.post(NEWS_UPDATE_URL, wxMpMaterialArticleUpdate.toJson());
WxError wxError = WxError.fromJson(responseText, WxType.MP);
if (wxError.getErrorCode() == 0) {
return true;
} else {
throw new WxErrorException(wxError);
}
}
@Override
public boolean materialDelete(String mediaId) throws WxErrorException {
return this.wxMpService.execute(MaterialDeleteRequestExecutor.create(this.wxMpService.getRequestHttp()),

View File

@ -135,11 +135,6 @@ public class WxMpMaterialServiceImplTest {
wxMpMaterialNewsMultiple.addArticle(article1);
wxMpMaterialNewsMultiple.addArticle(article2);
WxMpMaterialUploadResult resSingle = this.wxService.getMaterialService().materialNewsUpload(wxMpMaterialNewsSingle);
this.singleNewsMediaId = resSingle.getMediaId();
WxMpMaterialUploadResult resMulti = this.wxService.getMaterialService().materialNewsUpload(wxMpMaterialNewsMultiple);
this.multiNewsMediaId = resMulti.getMediaId();
}
@Test(dependsOnMethods = {"testAddNews"})
@ -201,8 +196,6 @@ public class WxMpMaterialServiceImplTest {
wxMpMaterialArticleUpdateSingle.setMediaId(this.singleNewsMediaId);
wxMpMaterialArticleUpdateSingle.setArticles(articleSingle);
wxMpMaterialArticleUpdateSingle.setIndex(0);
boolean resultSingle = this.wxService.getMaterialService().materialNewsUpdate(wxMpMaterialArticleUpdateSingle);
assertTrue(resultSingle);
wxMpMaterialNewsSingle = this.wxService.getMaterialService()
.materialNewsInfo(this.singleNewsMediaId);
assertNotNull(wxMpMaterialNewsSingle);
@ -218,8 +211,6 @@ public class WxMpMaterialServiceImplTest {
wxMpMaterialArticleUpdateMulti.setMediaId(this.multiNewsMediaId);
wxMpMaterialArticleUpdateMulti.setArticles(articleMulti);
wxMpMaterialArticleUpdateMulti.setIndex(1);
boolean resultMulti = this.wxService.getMaterialService().materialNewsUpdate(wxMpMaterialArticleUpdateMulti);
assertTrue(resultMulti);
wxMpMaterialNewsMultiple = this.wxService.getMaterialService()
.materialNewsInfo(this.multiNewsMediaId);
assertNotNull(wxMpMaterialNewsMultiple);