我發佈了這個爲php/curl,但我可以對任何工作解決方案開放。登錄表單需要首先加載頁面php curl
example.com/login.asp
具有登錄表單內隱藏的價值:
input type="hidden" name="security" value="123456789abcdef"
我試圖用捲曲來獲得這種額外的安全值,並將其包含到另一個但捲曲調用的第一個捲曲後更改了值。我已閱讀相關文章,建議使用php file_get_contents
,但它不適用於特定網站。
當前的PHP捲曲看起來是這樣的:
function curling ($websitehttps,$postfields,$cookie,$ref,$follow) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $websitehttps);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Connection: Close'));
curl_setopt($ch, CURLOPT_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_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if ($cookie != "") {
curl_setopt($ch, CURLOPT_COOKIE,$cookie);
}
if ($postfields != "") {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postfields);
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $follow);
curl_setopt($ch, CURLOPT_AUTOREFERER,TRUE);
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
我需要使用在後場額外的安全代碼($ postfields),它看起來應該像類似這樣的東西:
ref=https%3A%2F%2Fexample.com%2F&security=123456789abcdef
有沒有辦法做到這一點?
您是否確保第一個請求中的cookie傳遞給第二個?我假設如果不是,那就是安全價值會發生變化的原因。這是[快速谷歌搜索給我](http://coderscult.com/php-curl-cookies-example/)。 –
@ i--感謝您的準確提示,問題實際上是關於cookie。 – cenk