|
|
@@ -1,5 +1,7 @@ |
|
|
|
package me.chanjar.weixin.mp.api.impl; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import com.google.gson.JsonObject; |
|
|
|
import me.chanjar.weixin.common.error.WxErrorException; |
|
|
|
import me.chanjar.weixin.mp.api.WxMpService; |
|
|
@@ -8,13 +10,12 @@ import me.chanjar.weixin.mp.bean.WxMpUserQuery; |
|
|
|
import me.chanjar.weixin.mp.bean.result.WxMpUser; |
|
|
|
import me.chanjar.weixin.mp.bean.result.WxMpUserList; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* Created by Binary Wang on 2016/7/21. |
|
|
|
* |
|
|
|
* @author BinaryWang |
|
|
|
*/ |
|
|
|
public class WxMpUserServiceImpl implements WxMpUserService { |
|
|
|
private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/user"; |
|
|
|
private WxMpService wxMpService; |
|
|
|
|
|
|
|
public WxMpUserServiceImpl(WxMpService wxMpService) { |
|
|
@@ -23,11 +24,10 @@ public class WxMpUserServiceImpl implements WxMpUserService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void userUpdateRemark(String openid, String remark) throws WxErrorException { |
|
|
|
String url = API_URL_PREFIX + "/info/updateremark"; |
|
|
|
JsonObject json = new JsonObject(); |
|
|
|
json.addProperty("openid", openid); |
|
|
|
json.addProperty("remark", remark); |
|
|
|
this.wxMpService.post(url, json.toString()); |
|
|
|
this.wxMpService.post(USER_INFO_UPDATE_REMARK_URL, json.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@@ -37,32 +37,28 @@ public class WxMpUserServiceImpl implements WxMpUserService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public WxMpUser userInfo(String openid, String lang) throws WxErrorException { |
|
|
|
String url = API_URL_PREFIX + "/info"; |
|
|
|
lang = lang == null ? "zh_CN" : lang; |
|
|
|
String responseContent = this.wxMpService.get(url, |
|
|
|
String responseContent = this.wxMpService.get(USER_INFO_URL, |
|
|
|
"openid=" + openid + "&lang=" + lang); |
|
|
|
return WxMpUser.fromJson(responseContent); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public WxMpUserList userList(String next_openid) throws WxErrorException { |
|
|
|
String url = API_URL_PREFIX + "/get"; |
|
|
|
String responseContent = this.wxMpService.get(url, |
|
|
|
next_openid == null ? null : "next_openid=" + next_openid); |
|
|
|
public WxMpUserList userList(String nextOpenid) throws WxErrorException { |
|
|
|
String responseContent = this.wxMpService.get(USER_GET_URL, |
|
|
|
nextOpenid == null ? null : "next_openid=" + nextOpenid); |
|
|
|
return WxMpUserList.fromJson(responseContent); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<WxMpUser> userInfoList(List<String> openids) |
|
|
|
public List<WxMpUser> userInfoList(List<String> openidList) |
|
|
|
throws WxErrorException { |
|
|
|
return this.userInfoList(new WxMpUserQuery(openids)); |
|
|
|
return this.userInfoList(new WxMpUserQuery(openidList)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<WxMpUser> userInfoList(WxMpUserQuery userQuery) throws WxErrorException { |
|
|
|
String url = API_URL_PREFIX + "/info/batchget"; |
|
|
|
String responseContent = this.wxMpService.post(url, |
|
|
|
userQuery.toJsonString()); |
|
|
|
String responseContent = this.wxMpService.post(USER_INFO_BATCH_GET_URL, userQuery.toJsonString()); |
|
|
|
return WxMpUser.fromJsonList(responseContent); |
|
|
|
} |
|
|
|
|
|
|
|