下面给了我一个407错误,有人能看到我为什么或在哪里出错吗?我是一个代理人。我在这上面花了些时间。我用的是正确的凭证。谢谢
function pushMeTo($widgeturl,$text,$signature) {
$agent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12";
if (!function_exists("curl_init")) die("pushMeTo needs CURL module, please install CURL on your php.");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $widgeturl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:pass');
curl_setopt($ch, CURLOPT_PROXY, "IP");
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$page = curl_exec($ch); //or die("Curl exe failed");
print_r(curl_error($ch));
print_r($page);
preg_match("/form action='"(.*?)'"/", $page, $form_action);
preg_match("/textarea name='"(.*?)'"/", $page, $message_field);
preg_match("/input type='"text'" name='"(.*?)'"/", $page, $signature_field);
//print_r($message_field);
$ch = curl_init();
$strpost = $message_field[1].'=' . urlencode($text) . '&'.$signature_field[1].'=' . urlencode($signature);
curl_setopt($ch, CURLOPT_POSTFIELDS, $strpost );
curl_setopt($ch, CURLOPT_URL, $form_action[1]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$page = curl_exec($ch);
}
?>
<?
$url = "MY URL";
pushmeTo ($url,"This Is A Test","ServiceDesk");
?>
答案是:
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
之后一切正常!
尝试添加:
<>之前curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');//只是猜测之前如果这不起作用,然后检查是否加载了mod_proxy apache模块。如果它也加载了,那么尝试使用最新版本重新编译curl模块
检查底部,您使用该函数的地方。应该有大写字母m