com.tmsps.ne4weixin.api.UserAPI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ne4weixin Show documentation
Show all versions of ne4weixin Show documentation
Ne4WeiXin For Spring is good :)
package com.tmsps.ne4weixin.api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.tmsps.ne4weixin.bean.BaseResultBean;
import com.tmsps.ne4weixin.bean.UserInfo;
import com.tmsps.ne4weixin.config.WxConfig;
import com.tmsps.ne4weixin.utils.WXHttpUtil;
import lombok.extern.slf4j.Slf4j;
/**
* @Title: UserAPI.java
* @Package: com.tmsps.ne4weixin.api
* @Description: 公众号用户管理API
*/
@Slf4j
public class UserAPI extends BaseAPI {
public UserAPI(WxConfig wxConfig) {
super(wxConfig);
}
/**
* 获取用户基本信息
*
* @param openId
* @return
*/
public UserInfo getUserInfo(String openId) {
String url = String.format(USER_INFO, wxConfig.getAccessToken(), openId, "zh_CN");
String result = WXHttpUtil.get(url);
return JSONObject.parseObject(result, UserInfo.class);
}
/**
* 批量获取用户基本信息
*
* @param openids
* @return
*/
public List getUserInfos(List openids) {
String url = String.format(GET_USER_INFOS, wxConfig.getAccessToken());
JSONObject param = new JSONObject();
List