cURL代理问题407 [英] cURL Proxy issues 407

查看:360
本文介绍了cURL代理问题407的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下内容给我407错误,有人可以看到我为什么或哪里出错了吗?
我是代理人。
我已经花了一段时间了。
我使用的是正确的凭据。
谢谢


The Following gives me a 407 error, Can anyone see why or where I'm going wrong? I am behind a proxy. I have spent a while on this. I'm using the correct credentials. Thanks

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代理问题407的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆