**
*公衆號appId screret
*/
public static final String PAR_PUBLIC_APPID="";
public static final String PAR_PUBLIC_SECRET="";
/**
*獲取公衆號的token
*/
public static final String ACCESS_TOKEN="https://api.weixin.qq.com/cgi-bin/token";
/**
*獲取公衆號所有用戶的信息
*/
public static final String PUBLIC_USER_INFO="https://api.weixin.qq.com/cgi-bin/user/info";
/**
*獲取公衆號所有用戶的openId
*/
public static final String ALL_PUBLIC_USER_ID="https://api.weixin.qq.com/cgi-bin/user/get";
/**
*模板ID
*/
public static final String TEMPLATE_ID="";
/**
**獲取公衆號裏面所有用戶
**/
Map<String,String>allIdMap=Maps.newHashMap();
allIdMap.put("access_token",accessToken);
String userIds=HttpClientUtil.doGet(WechatAccountConfig.ALL_PUBLIC_USER_ID,allIdMap);
JSONObjectjsonUserIds=JSONObject.parseObject(userIds);
String dataStr=jsonUserIds.getString("data");
JSONObject dataJson=JSONObject.parseObject(dataStr);
/**
**循環獲取單個用戶的信息找到小程序用戶在公衆號中的openId
**/
String userIdArr=dataJson.getString("openid");
JSONArray userIdJsonArray=JSONArray.parseArray(userIdArr);
if(userIdJsonArray!=null&&userIdJsonArray.size()>0){
for(inti=0;i<userIdJsonArray.size();i++){
access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
Map<String,String>userMap=Maps.newHashMap();
userMap.put("access_token",accessToken);
userMap.put("openid",userIdJsonArray.get(i).toString());
userMap.put("lang","zh_CN");
String userInfos=HttpClientUtil.doGet(WechatAccountConfig.PUBLIC_USER_INFO,userMap);
JSONObjectjsonUser=JSONObject.parseObject(userInfos);
String publicId=jsonUser.getString("unionid");
if(StringUtils.equals(uniodId,publicId)){
publicOpenId=userIdJsonArray.get(i).toString();
redisUtils.set(publicKey,publicOpenId,1000*60*60*24);
}
}