【问题标题】:cURL Post Request throught proxy in PHP通过 PHP 中的代理的 cURL 发布请求
【发布时间】:2012-09-17 14:28:49
【问题描述】:

我想使用 cURL 进行 POST 请求,但通过 ip 代理服务器。代码是正确的,但我有一个空响应。

对于 GET 请求可以,但对于 POST 请求则不行。

我该怎么做?

提前谢谢你

编辑:下面的代码:

$ret = curl_setopt($c, CURLOPT_URL, $url);
$ret = curl_setopt($c, CURLOPT_POST, 1);
$ret = curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
$ret = curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
$ret = curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false);
if ($proxy != null) {
    $ret = curl_setopt($c, CURLOPT_HTTPPROXYTUNNEL, true);
    $ret = curl_setopt($c, CURLOPT_PROXY, $proxy);
    $ret = curl_setopt($c, CURLOPT_PROXYUSERPWD, $proxyident);
}
$ret = curl_exec($c);

【问题讨论】:

  • ..(不存在的)代码是正确的,但它不起作用?
  • 请提供更多信息,例如您正在运行的代码。
  • 是否涉及HTTPS?
  • 您的代码在不使用代理设置的情况下运行是否正确。如果它不是仅针对 post 数据类型运行,则意味着您没有以正确的格式传递 post 数据。

标签: php post curl proxy


【解决方案1】:

正如其他人所暗示的,您确实需要展示您的代码。从有限的信息来看,我认为您可能错过了允许 POST 的 setopt:

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

http://php.net/manual/en/function.curl-setopt.php

【讨论】:

    猜你喜欢
    • 2017-11-21
    • 2017-04-23
    • 1970-01-01
    • 2015-12-06
    • 2022-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多