Pārlūkot izejas kodu

添加批量为用户取消标签的接口

master
BinaryWang pirms 8 gadiem
vecāks
revīzija
6e32028c50
3 mainītis faili ar 35 papildinājumiem un 2 dzēšanām
  1. +10
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java
  2. +23
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java
  3. +2
    -2
      weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java

+ 10
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java Parādīt failu

@@ -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;

}

+ 23
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java Parādīt failu

@@ -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);
}
}

+ 2
- 2
weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java Parādīt failu

@@ -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);
}


Notiek ielāde…
Atcelt
Saglabāt