zoukankan      html  css  js  c++  java
  • 调用第三方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;
    // }

    历经苦难而不厌,此乃阿修罗之道。
  • 相关阅读:
    MySQL数据库时间查询
    MySQL函数转储存(当前月数据同步)
    字节数截取字符串
    JAVA 内部静态类--解析静态内部类的使用目的与限制
    Java集合框架学习总结
    JDBC中的Statement和PreparedStatement的区别
    java jdbc的优化之BeanUtils组件
    jdbc java数据库连接 11)中大文本类型的处理
    jdbc java数据库连接 10)批处理
    jdbc java数据库连接 9)事务编程
  • 原文地址:https://www.cnblogs.com/echo1314/p/11688593.html
Copyright © 2011-2022 走看看