【问题标题】:cURL Proxy issues 407cURL 代理问题 407
【发布时间】:2012-01-08 22:16:49
【问题描述】:

以下给我一个 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 的 wat 版本吗..?

标签: php curl proxy


【解决方案1】:

答案是添加:

curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

之后一切正常!

【讨论】:

    【解决方案2】:

    尝试添加:

    curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP'); // 只是猜测

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

    【讨论】:

    • 谢谢,但没用,我想我正在运行 5.3.5.0(php_curl.dll 属性)添加该行并没有改变任何内容,启用了 mod 代理。
    【解决方案3】:

    检查底部,您使用该功能的位置。应该有一个国会大厦M。

    【讨论】:

      猜你喜欢
      • 2020-04-21
      • 2021-08-21
      • 1970-01-01
      • 1970-01-01
      • 2020-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-04
      相关资源
      最近更新 更多