[Router] API program control various operations of the router

In this paper, TP-LINK, for example, explain how to operate the router through the program.

Enter the address of the router in the browser http://192.168.1.1/ you will be asked to enter a password authentication 401 

It can be seen by firebug return ahead logging in response to a field value Basic xxxxxxxxxxx ....... Authorization

This is the user name and password entered at login  

Check the router management interface of the router management html find broken links and files are /userRpm/StatusRpm.htm

Button in response to the link disconnection /userRpm/StatusRpm.htm?Disconnect= break & wan = 1

Now we use the Authorization procedure is added to the response sent in advance to /userRpm/StatusRpm.htm?Disconnect= break & wan = 1 can make the router disconnected

Parameters "break" may require transcoding of my router is utf8

  java Sample code:

// 生成url
URL url = new URL("http://192.168.1.1:8090/userRpm/StatusRpm.htm?Disconnect=%E6%96%AD%20%E7%BA%BF&wan=1"); // 打开链接 URLConnection connection = url.openConnection();
// 把
Authorization 字段 加到响应头里
connection.setRequestProperty("Authorization", "Basic ZnVoYW53OkpvaG4zNTc1NDA1NzQ=");
// 发送数据
connection.connect();
// 接收返回,不知道为什么不接收返回,就没有效果。。。
connection.getHeaderFields();

There are many other functions can be achieved using the above method, such as an automatic replacement of IP, etc. do not understand please review this article I will answer it

Reproduced in: https: //my.oschina.net/johnfu/blog/206920

Guess you like

Origin blog.csdn.net/weixin_34067102/article/details/91809114