|
@@ -0,0 +1,86 @@
|
|
|
+package cn.com.ctop.crawler.modules.core.util;
|
|
|
+
|
|
|
+import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
+
|
|
|
+public class KuaimiUtil {
|
|
|
+ public static final String KUAIMI_API_URL = "http://api.kmiyz.com/api/do.php";
|
|
|
+
|
|
|
+ public static String kuaimiLogin() throws Exception {
|
|
|
+ String result = HttpUtils.httpPostNoParamRequest(KUAIMI_API_URL + "?action=loginIn&name=xuzuoyun&password=heaven01");
|
|
|
+ if (result != null && result.startsWith("1")) {
|
|
|
+ System.out.println(result);
|
|
|
+ return result.split("\\|")[1];
|
|
|
+ } else {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getMobile(String token, String projectId) throws Exception {
|
|
|
+ String url = KUAIMI_API_URL + "?action=getPhone&sid=" + projectId + "&token=" + token;
|
|
|
+ String result = HttpUtils.httpPostNoParamRequest(url);
|
|
|
+ System.out.println(result);
|
|
|
+ if (result != null && result.startsWith("1")) {
|
|
|
+ System.out.println(result);
|
|
|
+ return result.split("\\|")[1];
|
|
|
+ } else {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getMessage(String token, String projectId, String phone) throws Exception {
|
|
|
+ String url = KUAIMI_API_URL + "?action=getMessage&sid=" + projectId + "&token=" + token + "&phone=" + phone;
|
|
|
+ String result = HttpUtils.httpPostNoParamRequest(url);
|
|
|
+ if (result != null && result.startsWith("1")) {
|
|
|
+ System.out.println(result);
|
|
|
+ return result.split("\\|")[1].substring(6, 12);
|
|
|
+ } else {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String addBlackList(String token, String projectId, String phone) throws Exception {
|
|
|
+ String url = KUAIMI_API_URL + "?action=addBlacklist&sid=" + projectId + "&token=" + token + "&phone=" + phone;
|
|
|
+ String result = HttpUtils.httpPostNoParamRequest(url);
|
|
|
+ if (result != null && result.startsWith("1")) {
|
|
|
+ System.out.println(result);
|
|
|
+ return result.split("\\|")[1];
|
|
|
+ } else {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String cancelRecv(String token, String projectId, String phone) throws Exception {
|
|
|
+ String url = KUAIMI_API_URL + "?action=cancelRecv&sid=" + projectId + "&token=" + token + "&phone=" + phone;
|
|
|
+ String result = HttpUtils.httpPostNoParamRequest(url);
|
|
|
+ if (result != null && result.startsWith("1")) {
|
|
|
+ System.out.println(result);
|
|
|
+ return result.split("\\|")[1];
|
|
|
+ } else {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ KuaimiUtil k = new KuaimiUtil();
|
|
|
+ try {
|
|
|
+ String token = k.kuaimiLogin();
|
|
|
+ System.out.println(token);
|
|
|
+ String mobile = k.getMobile(token, "2307");
|
|
|
+ int times = 0;
|
|
|
+ while (times < 100) {
|
|
|
+ Thread.sleep(5000);
|
|
|
+ try {
|
|
|
+ String msg = k.getMessage(token, "2307", mobile);
|
|
|
+ System.out.println(msg);
|
|
|
+ break;
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("等待短信");
|
|
|
+ }
|
|
|
+ times++;
|
|
|
+ }
|
|
|
+ System.out.println("完成");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|