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;
    // }

    历经苦难而不厌,此乃阿修罗之道。
  • 相关阅读:
    mzy git学习,分支以及分支合并(四)
    mzy git学习,删除文件(三)
    mzy git学习,撤销修改(二)
    mzy git学习,初识git(一)
    apche的BeanUtils避免使用!
    eclipse性能调优的一次记录
    Java规范化代码eclipse模板注释
    左倾堆(对两个优先队列合并)
    二叉堆的实现(数组)——c++
    哈夫曼树——c++
  • 原文地址:https://www.cnblogs.com/echo1314/p/11688593.html
Copyright © 2011-2022 走看看