我认为 POST 数据不会通过代理传递,因为响应就像没有 POST 数据的普通 HTTP 请求一样。系统日志显示Error: username/password is empty
。
cUrl POST 与代理一起使用时是否存在错误?
$proxyServer = "xxx";
$proxyPort = "8080";
$proxyUsername = "DOMAIN\XXX";
$proxyPassword = "YYY";
$postInformation = array(
"signin" => "yes",
"username" => "xxx",
"password" => "xxx",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $loginURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_PROXY, "$proxyServer:$proxyPort");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "$proxyUsername:$proxyPassword");
// Disable the SSL Verfication
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// HTTP POST
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postInformation));
// Enable Cookies
curl_setopt($ch, CURLOPT_COOKIE, 'cookie.txt');
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
$out = curl_exec($ch);
if (curl_error($ch)) {
echo "ERROR: " . curl_error($ch) . "\n";
}
if ($out) {
echo $out . "\n";
} else {
echo "ERROR: No reponse!\n";
}
curl_close($ch);