Mam problem z jedną ze stron mojego dostawcy, chcę ja "przejechać" curlem ale jest problem z tą stroną logowania:
<html>
<head>
<title>Konfiguracja....</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Set-Cookie" content="webid2=ABCDEFG;expires=31-DEC-2019 23:59:59 GMT;">
<meta http-equiv="Set-Cookie" content="session_id=nr_sesji;expires=31-DEC-2019 23:59:59 GMT;">
</head>
<body onLoad="document.mainform.submit();" bgcolor="#FFFFFF" background="images/main_back.gif" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" scroll="no">
<form name="mainform" action="homework" target="_top"></form>
</body>
</html>
Domyślam się, że to przez to przekierowanie: document.mainform.submit();
Bo pojawia się u mnie błąd: 404, nie odnaleziono /homework (testuję to na localhoscie)
Nie mogę podać url do strony, bo jest ona u mnie w intranecie i nie chciałbym jej podawać mimo wszystko.
Natomiast mój kod php wygląda tak:
$form_url='https://......../login';
$post_var = 'act=passcode&usr=IDENTYFIKATOR&location=homework';
$ch=curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_URL, $form_url);
curl_setopt($ch, CURLOPT_COOKIEJAR,'cookie-'.$name_site.'.txt');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1); //zmienne post
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_var);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //aby pomijac cert ssl
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
//ob_start(); // prevent any output
curl_exec($ch); // execute the curl command
//ob_end_clean(); // stop preventing output
//echo print_r(curl_getinfo($ch));echo "<br><br>";
echo curl_errno($ch);
curl_close ($ch);
unset($ch)
To główny fragment kodu. To co do przekazania w post podglądałem sobie w dodatku do firefoxa HttpFox.
Chociaż dziwi mnie, że potem obserwując ten swój kod nie widzę już w HttpFox żadnych danych POST, natomiast są tam dane GET, ale pewnie tak powinno to działać.