mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 13:06:54 +08:00
添加批量为用户取消标签的接口
This commit is contained in:
parent
9780d651d6
commit
6e32028c50
@ -76,4 +76,14 @@ public interface WxMpUserTagService {
|
||||
*/
|
||||
boolean batchTagging(Integer tagId, String[] openids) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 批量为用户取消标签
|
||||
* 详情请见:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140837&token=&lang=zh_CN">用户标签管理</a>
|
||||
* 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
boolean batchUntagging(Integer tagId, String[] openids) throws WxErrorException;
|
||||
|
||||
}
|
||||
|
@ -130,4 +130,27 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
|
||||
|
||||
throw new WxErrorException(wxError);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean batchUntagging(Integer tagId, String[] openids) throws WxErrorException {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging";
|
||||
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("tagid", tagId);
|
||||
JsonArray openidArrayJson = new JsonArray();
|
||||
for (String openid : openids) {
|
||||
openidArrayJson.add(openid);
|
||||
}
|
||||
json.add("openid_list", openidArrayJson);
|
||||
|
||||
String responseContent = this.wxMpService.post(url, json.toString());
|
||||
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(),
|
||||
responseContent);
|
||||
WxError wxError = WxError.fromJson(responseContent);
|
||||
if (wxError.getErrorCode() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new WxErrorException(wxError);
|
||||
}
|
||||
}
|
||||
|
@ -62,9 +62,9 @@ public class WxMpUserTagServiceImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatchTagging() throws Exception {
|
||||
public void testBatchUntagging() throws Exception {
|
||||
String[] openids = new String[]{((ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()};
|
||||
boolean res = this.wxService.getUserTagService().batchTagging(this.tagId, openids);
|
||||
boolean res = this.wxService.getUserTagService().batchUntagging(this.tagId, openids);
|
||||
System.out.println(res);
|
||||
Assert.assertTrue(res);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user