$this->curl = curl_init();
curl_setopt($this->curl, CURLOPT_URL, 'http://something.com/send');
curl_setopt($this->curl, CURLOPT_REFERER, 'http://something.com');
curl_setopt($this->curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1');
curl_setopt($this->curl, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($this->curl, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookies.txt');
curl_setopt($this->curl, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookies.txt');
curl_setopt($this->curl, CURLOPT_HTTPGET, 0);
curl_setopt($this->curl, CURLOPT_POST, 1);
curl_setopt($this->curl, CURLOPT_POSTFIELDS, 'name=john');
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($this->curl, CURLOPT_HTTPPROXYTUNNEL, FALSE);
curl_setopt($this->curl, CURLOPT_PROXY, $this->proxy['0']);
curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxy['1']);
curl_setopt($this->curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($this->curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_setopt($this->curl, CURLOPT_PROXYUSERPWD, $this->proxy['2'] . ':' . $this->proxy['3']);
curl_setopt($this->curl, CURLOPT_HEADER, 1);
curl_setopt($this->curl, CURLINFO_HEADER_OUT, 1);
curl_setopt($this->curl, CURLOPT_VERBOSE, 1);$this->website = curl_exec($this->curl);
var_dump(curl_getinfo($this->curl));
var_dump(curl_error($this->curl));
echo $this->website;
所以 getinfo 告诉我: GET http://something.com/send HTTP/1.1
而不是 POST http://something.com/send HTTP/1.1
这不是代理错误-我在没有代理的情况下尝试过-结果相同。
那么为什么 cURL 强制 GET 呢?而不是做正常的 POST 请求?