note 58689 modified in ref.curl by felipe
| From: | felipe@php.net | Date: | Sun, 30 Mar 2008 19:07:12 +0000 |
| Subject: | note 58689 modified in ref.curl by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-137769@lists.php.net to get a copy of this message | ||
To use proxy in cUrl, not only CURLOPT_PROXY parameter should be set but CURLOPT_HTTPPROXYTUNNEL (to
1 or true) and CURLOPT_PROXYUSERPWD (if proxy requires authorization) as it was written in the
cUrl's official documentation.
Working code should be something like this:
$cUrl = curl_init();
curl_setopt($cUrl, CURLOPT_URL, 'google.com');
curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cUrl, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($this->cUrl, CURLOPT_PROXY, 'proxy_name_or_ip:proxy_prot');
curl_setopt($this->cUrl, CURLOPT_PROXYUSERPWD, 'username:password');
$PageContent = curl_exec($cUrl);
curl_close($cUrl);
To be honest this code does not work on my server. Parameters different variation had tried but in
vain, the code still did not work. Finally personal proxy server was bought and checking started
again, the result was negative again.
Before bringing up this question here, it was asked on many different PHP forums but in vain, nobody
had the answer. There is only one suspicion: there is possibility that there is something wrong with
hosting where this code was tested.
To find the right answer the code should be tested in different hosting.
--was--
To use proxy in cUrl, not only CURLOPT_PROXY parameter should be set but CURLOPT_HTTPPROXYTUNNEL (to
1 or true) and CURLOPT_PROXYUSERPWD (if proxy requires authorization) as it was written in the
cUrls official documentation.
Working code should be something like this:
$cUrl = curl_init();
curl_setopt($cUrl, CURLOPT_URL, google.com);
curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cUrl, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($this->cUrl, CURLOPT_PROXY, 'proxy_name_or_ip:proxy_prot');
curl_setopt($this->cUrl, CURLOPT_PROXYUSERPWD, 'username:password');
$PageContent = curl_exec($cUrl);
curl_close($cUrl);
To be honest this code does not work on my server. Parameters different variation had tried but in
vain, the code still did not work. Finally personal proxy server was bought and checking started
again, the result was negative again.
Before bringing up this question here, it was asked on many different PHP forums but in vain, nobody
had the answer. There is only one suspicion: there is possibility that there is something wrong with
hosting where this code was tested.
To find the right answer the code should be tested in different hosting.
http://php.net/manual/en/ref.curl.php