|
|
|
@ -5,10 +5,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
|
|
import javax.crypto.Cipher; |
|
|
|
import javax.crypto.Cipher; |
|
|
|
import javax.crypto.spec.SecretKeySpec; |
|
|
|
import javax.crypto.spec.SecretKeySpec; |
|
|
|
import java.io.BufferedReader; |
|
|
|
import java.io.*; |
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
|
|
|
import java.io.OutputStreamWriter; |
|
|
|
|
|
|
|
import java.io.PrintWriter; |
|
|
|
|
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.net.URLEncoder; |
|
|
|
@ -54,7 +51,6 @@ public class SmsLan { |
|
|
|
String jsonStr = JSON.toJSONString(dataMap); |
|
|
|
String jsonStr = JSON.toJSONString(dataMap); |
|
|
|
log.info("jsonStr: {}", jsonStr); |
|
|
|
log.info("jsonStr: {}", jsonStr); |
|
|
|
String key = encrypt(jsonStr, PASSWORD); |
|
|
|
String key = encrypt(jsonStr, PASSWORD); |
|
|
|
log.info("key: {}", key); |
|
|
|
|
|
|
|
key = URLEncoder.encode(key, "UTF-8"); |
|
|
|
key = URLEncoder.encode(key, "UTF-8"); |
|
|
|
log.info("key: {}", key); |
|
|
|
log.info("key: {}", key); |
|
|
|
String response = httpUtilPost(BASE_URL, "userid=" + USERNAME + "&key=" + key); |
|
|
|
String response = httpUtilPost(BASE_URL, "userid=" + USERNAME + "&key=" + key); |
|
|
|
@ -88,7 +84,6 @@ public class SmsLan { |
|
|
|
String jsonStr = JSON.toJSONString(dataMap); |
|
|
|
String jsonStr = JSON.toJSONString(dataMap); |
|
|
|
log.info("jsonStr: {}", jsonStr); |
|
|
|
log.info("jsonStr: {}", jsonStr); |
|
|
|
String key = encrypt(jsonStr, PASSWORD); |
|
|
|
String key = encrypt(jsonStr, PASSWORD); |
|
|
|
log.info("key: {}", key); |
|
|
|
|
|
|
|
key = URLEncoder.encode(key, "UTF-8"); |
|
|
|
key = URLEncoder.encode(key, "UTF-8"); |
|
|
|
log.info("key: {}", key); |
|
|
|
log.info("key: {}", key); |
|
|
|
String response = httpUtilPost(BASE_URL, "userid=" + USERNAME + "&key=" + key); |
|
|
|
String response = httpUtilPost(BASE_URL, "userid=" + USERNAME + "&key=" + key); |
|
|
|
@ -120,7 +115,6 @@ public class SmsLan { |
|
|
|
String jsonStr = JSON.toJSONString(dataMap); |
|
|
|
String jsonStr = JSON.toJSONString(dataMap); |
|
|
|
log.info("jsonStr: {}", jsonStr); |
|
|
|
log.info("jsonStr: {}", jsonStr); |
|
|
|
String key = encrypt(jsonStr, PASSWORD); |
|
|
|
String key = encrypt(jsonStr, PASSWORD); |
|
|
|
log.info("key: {}", key); |
|
|
|
|
|
|
|
key = URLEncoder.encode(key, "UTF-8"); |
|
|
|
key = URLEncoder.encode(key, "UTF-8"); |
|
|
|
log.info("key: {}", key); |
|
|
|
log.info("key: {}", key); |
|
|
|
String response = httpUtilPost(BASE_URL, "userid=" + USERNAME + "&key=" + key); |
|
|
|
String response = httpUtilPost(BASE_URL, "userid=" + USERNAME + "&key=" + key); |
|
|
|
@ -133,42 +127,55 @@ public class SmsLan { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* POST 请求 |
|
|
|
* POST 请求 |
|
|
|
* |
|
|
|
|
|
|
|
* @param urls |
|
|
|
* @param urls |
|
|
|
* @param params |
|
|
|
* @param par |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static String httpUtilPost(String urls, String params) { |
|
|
|
public static String httpUtilPost(String urls, String par) { |
|
|
|
URL url; |
|
|
|
URL url; |
|
|
|
HttpURLConnection uConn = null; |
|
|
|
HttpURLConnection uConn = null; |
|
|
|
String result = ""; |
|
|
|
String sResult = ""; |
|
|
|
|
|
|
|
BufferedReader in = null; |
|
|
|
|
|
|
|
PrintWriter out = null; |
|
|
|
|
|
|
|
String line = ""; |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
sResult = ""; |
|
|
|
url = new URL(urls); |
|
|
|
url = new URL(urls); |
|
|
|
uConn = (HttpURLConnection) url.openConnection(); |
|
|
|
uConn = (HttpURLConnection) url.openConnection(); |
|
|
|
uConn.setRequestMethod("POST"); |
|
|
|
uConn.setRequestMethod("POST"); |
|
|
|
|
|
|
|
System.setProperty("sun.net.client.defaultConnectTimeout", String.valueOf(10000)); |
|
|
|
|
|
|
|
System.setProperty("sun.net.client.defaultReadTimeout", String.valueOf(10000)); |
|
|
|
uConn.setDoInput(true); |
|
|
|
uConn.setDoInput(true); |
|
|
|
uConn.setDoOutput(true); |
|
|
|
uConn.setDoOutput(true); |
|
|
|
uConn.connect(); |
|
|
|
uConn.connect(); |
|
|
|
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(uConn.getOutputStream(), "utf-8")); |
|
|
|
out = new PrintWriter(new OutputStreamWriter(uConn.getOutputStream(), "utf-8")); |
|
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(uConn.getInputStream(), "utf-8"))) { |
|
|
|
out.write(par); |
|
|
|
out.write(params); |
|
|
|
out.flush(); |
|
|
|
out.flush(); |
|
|
|
out.close(); |
|
|
|
StringBuilder resultBuilder = new StringBuilder(); |
|
|
|
in = new BufferedReader(new InputStreamReader(uConn.getInputStream(), "utf-8")); |
|
|
|
String line; |
|
|
|
while ((line = in.readLine()) != null) { |
|
|
|
while ((line = in.readLine()) != null) { |
|
|
|
if (line.length() > 0) |
|
|
|
if (line.length() > 0) |
|
|
|
sResult += line; |
|
|
|
resultBuilder.append(line); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result = resultBuilder.toString(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
in.close(); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
if (uConn != null) { |
|
|
|
try { |
|
|
|
uConn.disconnect(); |
|
|
|
if (null != in) |
|
|
|
|
|
|
|
in.close(); |
|
|
|
|
|
|
|
in = null; |
|
|
|
|
|
|
|
if (null != out) |
|
|
|
|
|
|
|
out.close(); |
|
|
|
|
|
|
|
out = null; |
|
|
|
|
|
|
|
if (null != uConn) |
|
|
|
|
|
|
|
uConn.disconnect(); |
|
|
|
|
|
|
|
uConn = null; |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return sResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|