🐛 #2799 [ 企业微信】修复第三方服务调用getUserId接口时缺少access_token的问题

This commit is contained in:
cocoa 2022-10-21 17:49:10 +08:00 committed by GitHub
parent 9b78acd0e5
commit a8a5359c9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -162,10 +162,11 @@ public interface WxCpTpUserService {
* </pre>
*
* @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;
/**
* 获取外部联系人详情.

View File

@ -186,10 +186,11 @@ public class WxCpTpUserServiceImpl implements WxCpTpUserService {
}
@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);
String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_USER_ID)
+ "?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();