diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java index c15a4ec2..79259957 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java @@ -427,22 +427,13 @@ public class WxCpServiceImpl implements WxCpService { @Override public String[] oauth2getUserInfo(String code) throws WxErrorException { - String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?"; - url += "access_token=" + wxCpConfigStorage.getAccessToken(); - url += "&code=" + code; - url += "&agendid=" + wxCpConfigStorage.getAgentId(); - - try { - RequestExecutor executor = new SimpleGetRequestExecutor(); - String responseText = executor.execute(getHttpclient(), httpProxy, url, null); - JsonElement je = Streams.parse(new JsonReader(new StringReader(responseText))); - JsonObject jo = je.getAsJsonObject(); - return new String[] {GsonHelper.getString(jo, "UserId"), GsonHelper.getString(jo, "DeviceId")}; - } catch (ClientProtocolException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } + String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?" + + "code=" + code + + "&agendid=" + wxCpConfigStorage.getAgentId(); + String responseText = get(url, null); + JsonElement je = Streams.parse(new JsonReader(new StringReader(responseText))); + JsonObject jo = je.getAsJsonObject(); + return new String[] {GsonHelper.getString(jo, "UserId"), GsonHelper.getString(jo, "DeviceId")}; } @Override