mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-24 13:03:46 +08:00
issue #1 添加分组管理接口-查询用户所在分组
This commit is contained in:
@@ -38,6 +38,7 @@ import chanjarster.weixin.util.http.MediaUploadRequestExecutor;
|
||||
import chanjarster.weixin.util.http.RequestExecutor;
|
||||
import chanjarster.weixin.util.http.SimpleGetRequestExecutor;
|
||||
import chanjarster.weixin.util.http.SimplePostRequestExecutor;
|
||||
import chanjarster.weixin.util.json.GsonHelper;
|
||||
import chanjarster.weixin.util.json.WxGsonBuilder;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -210,6 +211,13 @@ public class WxServiceImpl implements WxService {
|
||||
return WxGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement.getAsJsonObject().get("groups"), new TypeToken<List<WxGroup>>(){}.getType());
|
||||
}
|
||||
|
||||
public long groupQueryUserGroup(String openid) throws WxErrorException {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/groups/getid";
|
||||
String responseContent = execute(new SimplePostRequestExecutor(), url, MessageFormat.format("'{'\"openid\":\"{0}\"}", openid));
|
||||
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
|
||||
return GsonHelper.getAsLong(tmpJsonElement.getAsJsonObject().get("groupid"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求
|
||||
* @param executor
|
||||
|
Reference in New Issue
Block a user