4
我正在嘗試登錄到站點。本網站使用自動提交表單和隨機密鑰提交表單。我嘗試了幾種方法,但無法通過。所以這裏是我的代碼。任何答案將不勝感激。提前致謝。還有我的假帳戶通行證和用戶名可用代碼爲那些想嘗試。我的網址有點長使用curl登錄到https站點
include 'simple_html_dom.php';
$i = 0;
$html = file_get_html($url);
foreach($html->find('input') as $keys) {
$ltkey = $keys->value;
if (++ $i == 1)
break;
}
$url = 'https://auth.station.sony.com/login?theme=poxnora&cid=1056360&service=https://poxnora.station.sony.com/cas/merge.do®Service=https://poxnora.station.sony.com /play/load.do';
$data = 'lt=' . $ltkey . '&_eventId=submit&username=XXXXXXXX&password=XXXXXXXX';
// curl request
$fp = fopen("cookie.txt", "w");
fclose($fp);
$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);
curl_setopt($login, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($login, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($login, CURLOPT_CAINFO, "cert.crt");
$result = curl_exec($login);
curl_close($login);
echo $result;
'CURLOPT_SSL_VERIFYHOST'是'2',但你沒有添加證書......看到http://stackoverflow.com/questions/16374126/code-does-not-work -without-disabling-ssl/16374178#16374178關於如何向SSL請求添加證書 – Baba
用curl_error()檢查你的代碼http://php.net/manual/en/function.curl-error.php – Shin
謝謝你我都增加了證書,但它仍然重定向到登錄頁面,我也檢查了捲曲錯誤。沒有捲曲錯誤我在做什麼worng? –