????????????????????????????????accessToken.setExpiresIn(jsonObject.getInt("expires_in"));
????????????????????????} catch (JSONException e) {
????????????????????????????????accessToken = null;
????????????????????????????????// 获取token失败
????????????????????????????????log.error("获取token失败 errcode:{} errmsg:{}", jsonObject.getInt("errcode"), jsonObject.getString("errmsg"));
????????????????????????}
????????????????}
????????????????return accessToken;
????????}
????????
????????
????????/**
??????????* 描述: ??发起https请求并获取结果
??????????* @param requestUrl 请求地址
??????????* @param requestMethod 请求方式(GET、POST)
??????????* @param outputStr 提交的数据
??????????* @return JSONObject(通过JSONObject.get(key)的方式获取json对象的属性值)
??????????*/
????????public static JSONObject httpRequest(String requestUrl, String requestMethod, String outputStr) {
????????????????JSONObject jsonObject = null;
????????????????StringBuffer buffer = new StringBuffer();
????????????????try {
????????????????????????// 创建SSLContext对象,并使用我们指定的信任管理器初始化
????????????????????????TrustManager[] tm = { new MyX509TrustManager() };
????????????????????????SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
????????????????????????sslContext.init(null, tm, new java.security.SecureRandom());
????????????????????????// 从上述SSLContext对象中得到SSLSocketFactory对象
????????????????????????SSLSocketFactory ssf = sslContext.getSocketFactory();
??
????????????????????????URL url = new URL(requestUrl);
????????????????????????HttpsURLConnection httpUrlConn = (HttpsURLConnection) url.openConnection();
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/sanxing/article-69154-7.html
这充分说明我国強大的国防能力