调用第三方http接口

// /**
// * 调用第三方接口查询指定账号的信息
// * @param uid 账号
// * @return 用户信息
// */
// @Override
// public UserInfo matchUserInfo(String uid) {
// // // 记录日志
// // FileOperateLogReq fileOperateLog = LogParamUtil.getLogParam();
// // // 设置日记录菜单
// // fileOperateLog.setLeveOneMenu("系统管理");
// // fileOperateLog.setLeveTwoMenu("账号管理");
// // fileOperateLog.setOperateType("查询");
// // logDao.noteFileOperate(fileOperateLog);
// // 创建Httpclient对象
// CloseableHttpClient httpClient = HttpClients.createDefault();
// CloseableHttpResponse response = null;
// String url = "https://login-beta.huawei.com/sso/rest/user";
// String resultString = "";
// UserInfo userInfo = new UserInfo();
// try {
// // 创建uri
// URIBuilder builder = new URIBuilder(url + "/" + uid);
// URI uri = builder.build();
// // 创建Http Get请求
// HttpGet httpGet = new HttpGet(uri);
// // 执行http请求
// response = httpClient.execute(httpGet);
// if (response.getEntity() == null) {
// return userInfo;
// }
// resultString = EntityUtils.toString(response.getEntity(), "utf-8");
// userInfo = JSON.parseObject(resultString, UserInfo.class);
// } catch (URISyntaxException e) {
// if (DEBUG_LOGGER.isInfoEnabled()) {
// DEBUG_LOGGER.info("exception infomation:", e.getMessage());
// }
// } catch (ClientProtocolException e) {
// if (DEBUG_LOGGER.isInfoEnabled()) {
// DEBUG_LOGGER.info("exception infomation:", e.getMessage());
// }
// } catch (IOException e) {
// if (DEBUG_LOGGER.isInfoEnabled()) {
// DEBUG_LOGGER.info("exception infomation:", e.getMessage());
// }
// } catch (JSONException e) {
// if (DEBUG_LOGGER.isInfoEnabled()) {
// DEBUG_LOGGER.info("exception infomation:", e.getMessage());
// }
// } finally {
// try {
// if (response != null) {
// response.close();
// }
// } catch (IOException e) {
// if (DEBUG_LOGGER.isInfoEnabled()) {
// DEBUG_LOGGER.info("exception infomation:", e.getMessage());
// }
// }
// }
// return userInfo;
// }

猜你喜欢

转载自www.cnblogs.com/echo1314/p/11688593.html
今日推荐