优化获取小米路由器后台token
This commit is contained in:
@@ -10,8 +10,16 @@ import java.util.Date;
|
||||
|
||||
public class XiaoMiRouter {
|
||||
private final static String key = "a2ffa5c9be07488bbb04a3a47d3c5f6a";
|
||||
private static String token = null;
|
||||
|
||||
public static void setNotToken() {
|
||||
token = null;
|
||||
}
|
||||
|
||||
public static String getToken() {
|
||||
if (token != null) {
|
||||
return token;
|
||||
}
|
||||
String nonce = nonceCreat();
|
||||
String oldPwd = DigestUtils.sha1Hex(nonce + DigestUtils.sha1Hex("34864394" + key));
|
||||
JSONObject json = new JSONObject();
|
||||
@@ -21,7 +29,8 @@ public class XiaoMiRouter {
|
||||
json.put("nonce", nonce);
|
||||
json = JSONObject.parseObject(HttpTools.http_post("http://192.168.31.1/cgi-bin/luci/api/xqsystem/login", HttpTools.toUrlParams(json).getBytes(StandardCharsets.UTF_8), 1, null));
|
||||
if (json.getInteger("code") == 0) {
|
||||
return json.getString("token");
|
||||
token = json.getString("token");
|
||||
return token;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user