diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpUserService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpUserService.java index dcda4bae41..0f2fc5dd99 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpUserService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpUserService.java @@ -162,10 +162,11 @@ public interface WxCpTpUserService { * * * @param mobile 手机号码。长度为5~32个字节 + * @param corpId – the corp id * @return userid mobile对应的成员userid * @throws WxErrorException . */ - String getUserId(String mobile) throws WxErrorException; + String getUserId(String mobile, String corpId) throws WxErrorException; /** * 获取外部联系人详情. diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java index 6cbca3bd00..c938b93685 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java @@ -186,10 +186,11 @@ public String openid2UserId(String openid) throws WxErrorException { } @Override - public String getUserId(String mobile) throws WxErrorException { + public String getUserId(String mobile, String corpId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("mobile", mobile); String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_USER_ID); + url += "&access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId); String responseContent = this.mainService.post(url, jsonObject.toString()); JsonObject tmpJsonElement = GsonParser.parse(responseContent); return tmpJsonElement.getAsJsonObject().get("userid").getAsString();