cURL代理问题407

时间:2011-11-29 15:08:00

标签: php curl proxy

以下给我一个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");

?>

3 个答案:

答案 0 :(得分:1)

尝试添加:

curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP'); // just a guess 

如果这对您不起作用,请检查是否加载了mod_proxy apache模块。 如果还加载了,那么尝试使用最新版本重新编译curl模块 希望它可以帮助您进行调试。

答案 1 :(得分:1)

答案是补充:

curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

之后一切正常!

答案 2 :(得分:0)

检查底部,您在哪里使用该功能。应该有一个资本M.