添加获取标签下粉丝列表的接口

This commit is contained in:
BinaryWang
2016-09-20 21:03:55 +08:00
parent 63c41d44ab
commit c5c8628668
4 changed files with 138 additions and 16 deletions

View File

@@ -1,10 +1,11 @@
package me.chanjar.weixin.mp.api;
import java.util.List;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.bean.tag.WxTagListUser;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import java.util.List;
/**
* 用户标签管理相关接口
* Created by Binary Wang on 2016/9/2.
@@ -55,4 +56,14 @@ public interface WxMpUserTagService {
*/
Boolean tagDelete(Integer id) 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/user/tag/get?access_token=ACCESS_TOKEN
* </pre>
*
*/
WxTagListUser tagListUser(Integer tagId, String nextOpenid) throws WxErrorException;
}

View File

@@ -1,17 +1,17 @@
package me.chanjar.weixin.mp.api.impl;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.JsonObject;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.WxMpUserTagService;
import me.chanjar.weixin.mp.bean.tag.WxTagListUser;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
*
@@ -92,4 +92,18 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
throw new WxErrorException(wxError);
}
@Override
public WxTagListUser tagListUser(Integer tagId, String nextOpenid) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/user/tag/get";
JsonObject json = new JsonObject();
json.addProperty("tagid", tagId);
json.addProperty("next_openid", StringUtils.trimToEmpty(nextOpenid));
String responseContent = this.wxMpService.post(url, json.toString());
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(),
responseContent);
return WxTagListUser.fromJson(responseContent);
}
}