Mam mały problem.
Potrzebuję pobrać pewne dane z serwera, który wymaga logowania. Znalazłem skrypt, lecz nie działa to tak jak powinno.
Logowanie następuje poprawnie, ale nie wyświetla mi się żądana strona.
Skorzystałem ze skryptu:
<?php //Upload a blank cookie.txt to the same directory as this file with a CHMOD/Permission to 777 function login($url,$data){ $login = curl_init(); curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($login, CURLOPT_TIMEOUT, 40000); curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($login, CURLOPT_URL, $url); curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($login, CURLOPT_POST, TRUE); curl_setopt($login, CURLOPT_POSTFIELDS, $data); return curl_exec ($login); curl_close ($login); } function grab_page($site){ $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_TIMEOUT, 40); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($ch, CURLOPT_URL, $site); return curl_exec ($ch); curl_close ($ch); } function post_data($site,$data){ $datapost = curl_init(); curl_setopt($datapost, CURLOPT_URL, $site); curl_setopt($datapost, CURLOPT_TIMEOUT, 40000); curl_setopt($datapost, CURLOPT_HEADER, TRUE); curl_setopt($datapost, CURLOPT_HTTPHEADER, $headers); curl_setopt($datapost, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($datapost, CURLOPT_POST, TRUE); curl_setopt($datapost, CURLOPT_POSTFIELDS, $data); curl_setopt($datapost, CURLOPT_COOKIEFILE, "cookie.txt"); return curl_exec ($datapost); curl_close ($datapost); } ?> <?php echo login("http://30.30.3.210/cgi-bin/handle_login.tcl", "user=user&pw=pw&submit=Login&sid=&setLanguage="); ?>
Przy pierwszym wywołaniu skryptu mojeip/layouts/testowy/fototest.php
zostaję przeniesiony do mojeip/cgi-bin/frameset.tcl?sid=7652593734337927333
i strona się nie wyświetla.
Przy drugim wywołaniu zostaję na stronie mojeip/layouts/testowy/fototest.php
Ale zamiast żądanej strony dostaję komunikat o tym, że jestem już zalogowany na serwer.
Sorry, someone else is using the web interface right now,
please wait until they log out or their session times out!
The session timeout is 10 minutes.
Please click here to try again after some time.
Czy mógłbym prosić o pomoc?
Mam nadzieję, że nie tłumaczyłem zawile...