note 58689 deleted from ref.curl by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 19:36:10 +0000 |
| Subject: | note 58689 deleted from ref.curl by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155239@lists.php.net to get a copy of this message | ||
Note Submitter: administrator at gesoft dot org
----
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.