Confusing cURL and proxy options
This night I’ve been trying to use cURL to fetch some content of a website using PHP-CURL library. And because I did the work while I’m at my campus, which is using some proxy to connect to the net, I should configure cURL to use proxy.
Okay, then I read the PHP manual *gosh, long time no see this thing* … and found few variables that seems need to be configured so I could use proxy … which is …
- CURLOPT_HTTPPROXYTUNNEL : TRUE to tunnel through a given HTTP proxy.
- CURLOPT_PROXY : The HTTP proxy to tunnel requests through.
- CURLOPT_PROXYPORT : The port number of the proxy to connect to. This port number can also be set in CURLOPT_PROXY.
- CURLOPT_PROXYUSERPWD : A username and password formatted as “[username]:[password]“ to use for the connection to the proxy.
So I wrote these lines of code …
curl_setopt($ch,CURLOPT_HTTPPROXYTUNNEL,1);
curl_setopt($ch,CURLOPT_PROXY,’ip.addr.of.proxy’);
curl_setopt($ch,CURLOPT_PROXYPORT,’****’);
curl_setopt($ch,CURLOPT_PROXYUSERPWD,’****:****’);
and guess what … some response showed up …
Received HTTP code 403 from proxy after CONNECT
Okay … what’s this??? !@#$%^&^%$#@#$%
Few more read here and there … found the problems. It seems that I mistakely understands stuff about CURLOPT_HTTPPROXYTUNNEL. It somehow doesn’t related to the kind of proxy my campus have (correct me if I’m wrong here). At first I think that whenever I use proxy, then that variable should be set to TRUE. But no, I think that variable is only used whenever I need to use the proxy as a tunneling service for my connection, not as a real proxy. Dunno that’s true or not, but the problems is gone when I deleted the line.
Resource:
- http://id2.php.net/manual/en/function.curl-setopt.php
- http://curl.haxx.se/mail/curlphp-2008-07/0006.html
Recent Comments