這裏是我的代碼來處理此重定向:如何使用cURL
echo post_data("http://www.ifreewind.net/iFreeWind.aspx",
"__VIEWSTATE=%2FwEPDwULLTE3NjQ3MDc3NDQPZBYCAgMPZBYCAgEPFgIeB1Zpc2libGVoZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAQUSUmVtZW1iZXJNZUNoZWNrQm94r57YdIUtbSps%2FGLW1PUtjxcILdE%3D&__EVENTVALIDATION=%2FwEWBQLKivfjBgLw2N3fDgLC9%2FChAwLxuKbKAgL%2BjNCfDwU6DJjH4Q2acTlGVXmDrSv2Nn4G&UserNameTextBox=myemailaddress%40gmail.com&PasswordTextBox=mypassword&LoginButton=%E7%99%BB%E9%99%86");
function post_data($site, $data){
$datapost = curl_init();
$headers = array("Expect:");
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");
ob_start();
return curl_exec($datapost);
ob_end_clean();
curl_close($datapost);
unset($datapost);
}
post_data()函數的第二個參數,是用我的HttpFox產生的Firefox插件的結果。這些代碼不起作用,因爲這個地址自動重定向到
http://www.ifreewind.net/Users/Index.aspx,所以我失敗了,請幫我通過授權。
很酷,這真的有用! – Phoenix