Logowanie:
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; $curl = curl_init('http://192.168.1.1/authenticate?username=admin&password=admin'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_USERAGENT, $useragent); curl_setopt($curl, CURLOPT_POSTFIELDS,'username=admin&password=admin'); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_COOKIESESSION, true); curl_setopt($curl, CURLOPT_COOKIEJAR, '/tmp/ipreset_cookie.jar'); curl_setopt($curl, CURLOPT_COOKIEFILE, '/tmp/ipreset_cookie.txt');
To chyba działa, bo uzyskuje ssid jako set-cookie...
Restart połączenia:
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/x-sah-ws-1-call+json; charset=UTF-8','X-Context:'.$context,'X-Prototype-Version:1.7','X-Requested-With:XMLHttpRequest','Referer:http://192.168.1.1/advConfigAccessType.html')); curl_setopt($curl, CURLOPT_URL, 'http://192.168.1.1/sysbus/NeMo/Intf/data:setFirstParameter'); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, '{"parameters":{"name":"Enable","value":1,"flag":"ppp","traverse":"down"}}'); curl_setopt($curl, CURLINFO_HEADER_OUT, true); curl_exec($curl);
I tutaj gorzej... jeśli nie zaloguję się wcześniejszym, dostaję błąd "error: access denied", czy coś w tym stylu... ale po poprawnym zalogowaniu, powyższe zwraca tylko "status: null" - dokładnie to samo co przeglądarce przez interface webowy, ale... ale to nie działa. W sensie nie następuje restart połączenia.
Ktoś mógłby mi z tym pomóc? Najlepiej, jeśli ma tego FunBoxa...