这不是客户端操作,它是服务器端操作。不需要“form2”。您想为此使用curl。类似这样的:
// Set up a connection to the target of form1 (this is the "action" attribute of form1)
$curl_connection = curl_init('http://hostname.com/form1.asp');
// Set up so options -- connection timout, store to string, follow redirects
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
// Set the post fields, this is just like a query string and contains the contents of form1 fields
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, "field1=value1&field2=value2");
// Run the query and capture the results
$data = curl_exec($curl_connection);
curl_close($curl_connection);
// At this point $data should contain the ticket number
var_dump($data);
不幸的是,它必须是客户端操作。 “form1”服务器不会接受任何不协商NTLM身份验证的连接。所以我必须让它看起来像在互联网浏览器的用户提交表单。上面的解决方案是一个很棒的解决方案,但是我试过了:(服务器响应“未授权”,我尝试以明文形式发送密码,但它也不喜欢这样。 – 2011-01-27 06:05:57