晚上好。 我試圖做一個用PHP保留的jsp區域。 利用「高級REST cleint」 Chrome瀏覽器,我可以在登錄系統,查看在這樣的頁面的內容:PHP - Scar JSP JSP - HTTP狀態400
1)GET請求www.website.com 頭給我的JSESSIONID,我將使用對於將來的請求
2)GET請求www.website.com/login.jsp
3)POST請求www.website.com/i_security_check 後變量:爲j_username,爲j_password,提交utente
4)GET請求www.website.com/reserved_area.jsp
如果我嘗試做這種「算法」與PHP捲曲,在第三步我得到以下錯誤:HTTP狀態400 - 無效的直接引用,形成的登錄頁面
這是PHP代碼:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.website.com");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
$server_output = curl_exec ($ch);
curl_close ($ch);
$step1 = explode("JSESSIONID=", $server_output);
$step2 = explode("; ", $step1[1]);
$JSESSIONID = $step2[0];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.website.com/login.jsp");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: JSESSIONID=".$JSESSIONID));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
$server_output = curl_exec ($ch);
curl_close ($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.website.com/i_security_check");
curl_setopt($ch, CURLOPT_POST, 1);
$data = array("j_password" => "PASSWORD", "j_username" => "USERNAME", "submit" => "Entra", "utente" =>"USERNAME");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: JSESSIONID=".$JSESSIONID, "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3", "Connection: keep-alive", "Host: www.website.com", "Referer: https://www.website.com/login.jsp", "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "www.website.com/reserved_area.jsp");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: JSESSIONID=".$JSESSIONID, "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3", "Connection: keep-alive", "Host: www.website.com", "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
?>
任何想法? 謝謝
沒有改善... –