Use php to log on to tplink WR882N to obtain the IP address and restart tplinkwr882n.
This example describes how to log on to tplink WR882N in php to obtain the IP address and restart it. We will share this with you for your reference. The details are as follows:
When the server uploads Big Data tplink WR882N, it is easy to get stuck and cannot get online. we plan to conduct regular detection on the server. If we find that the specified website cannot be accessed for 10 consecutive times, the system will automatically restart the server (this part is not implemented, please add it yourself ).
Gg found that only the old version of the tplink login script had been used for a long time and failed-The tplink 740N in the house was okay.
So I can only write it directly. The simple script is as follows and can be expanded by myself.
This script only applies to WR882N, and other models are not tested.
<? Php // TPLINK WR882N management Script function getContent ($ url) {// obtain the url $ temp = parse_url ($ url ); $ query = isset ($ temp ['query'])? $ Temp ['query']: ''; $ path = isset ($ temp ['path'])? $ Temp ['path']: '/'; $ header = array ("POST {$ path }? {$ Query} HTTP/1.1 "," Host: {$ temp ['host']} "," Content-Type: text/xml; charset = UTF-8 ", 'Accept: text/html, application/xhtml + xml, application/xml; q = 0.9, image/webp, */*; q = 0.8 ', 'cookie: Authorization = Basic '. base64_encode ("admin: admin"), // note the cookie authentication string "Referer: http: // {$ temp ['host']}/", 'User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1) ', "Content-length: 380", "Connection: Clo Se "); $ curl = curl_init (); // start a CURL session curl_setopt ($ curl, CURLOPT_URL, $ url); // curl_setopt ($ curl, CURLOPT_HTTPHEADER, $ header); // curl_setopt ($ curl, CURLOPT_TIMEOUT, 60) Where header information is set; // set timeout limit to prevent endless loops curl_setopt ($ curl, CURLOPT_HEADER, 0); // display the returned Header area content curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); // The obtained information returns $ content = curl_exec ($ curl) as a file stream ); // execute curl_close ($ curl); return $ conten T;} function getIp () {$ content = getContent ("http: // 192.168.1.1/userRpm/StatusRpm.htm"); preg_match ('/wanPara = new Array \((. + ?) <\/Script>/s', $ content, $ all); $ ip = "0"; if (! Empty ($ all [1]) {$ data = trim ($ all [1]); $ data = str_replace ("\ r \ n ","", $ data); $ data = explode (",", $ data); $ ip = str_replace ('"','', $ data [2]); $ ip = trim ($ ip);} return $ ip;} function reboot () {$ url = "http: // 192.168.1.1/userRpm/SysRebootRpm.htm? Reboot = % D6 % D8 % C6 % F4 % C2 % B7 % D3 % C9 % C6 % F7 "; getContent ($ url) ;}$ info = getIp (); echo $ info;