#312 添加 删除群发 的接口

This commit is contained in:
Binary Wang 2017-08-22 23:43:21 +08:00
parent bc80845385
commit 3bc9dbd795
3 changed files with 38 additions and 0 deletions

View File

@ -34,6 +34,10 @@ public interface WxMpMassMessageService {
* 群发消息预览接口
*/
String MESSAGE_MASS_PREVIEW_URL = "https://api.weixin.qq.com/cgi-bin/message/mass/preview";
/**
* 删除群发接口
*/
String MESSAGE_MASS_DELETE_URL = "https://api.weixin.qq.com/cgi-bin/message/mass/delete";
/**
* <pre>
@ -92,4 +96,24 @@ public interface WxMpMassMessageService {
*/
WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception;
/**
* <pre>
* 删除群发
* 群发之后随时可以通过该接口删除群发
* 请注意
* 1只有已经发送成功的消息才能删除
* 2删除消息是将消息的图文详情页失效已经收到的用户还是能在其本地看到消息卡片
* 3删除群发消息只能删除图文消息和视频消息其他类型的消息一经发送无法删除
* 4如果多次群发发送的是一个图文消息那么删除其中一次群发就会删除掉这个图文消息也导致所有群发都失效
* 接口调用请求说明
* http请求方式: POST
* https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=ACCESS_TOKEN
* 详情请见https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1481187827_i0l21
* </pre>
*
* @param msgId 发送出去的消息ID
* @param articleIndex 要删除的文章在图文消息中的位置第一篇编号为1该字段不填或填0会删除全部文章
*/
void delete(Integer msgId, Integer articleIndex) throws Exception;
}

View File

@ -1,5 +1,6 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.gson.JsonObject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpMassMessageService;
import me.chanjar.weixin.mp.api.WxMpService;
@ -55,4 +56,12 @@ public class WxMpMassMessageServiceImpl implements WxMpMassMessageService {
return WxMpMassSendResult.fromJson(responseContent);
}
@Override
public void delete(Integer msgId, Integer articleIndex) throws Exception {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("msg_id", msgId);
jsonObject.addProperty("article_idx", articleIndex);
this.wxMpService.post(MESSAGE_MASS_DELETE_URL, jsonObject.toString());
}
}

View File

@ -181,4 +181,9 @@ public class WxMpMassMessageServiceImplTest {
return messages;
}
@Test
public void testMassDelete() throws Exception {
this.wxService.getMassMessageService().delete(1,2);
}
}