Saturday, October 31, 2009

PHP: Using curl with private proxies

Share at Facebook

Curl is a supper thing. You can do whatever you like. It has almost every functionality for your needs. I'm a fan of CURL.

Lets say you need to authenticate your proxy with a particular username and password. Using curl its just one single line of code. The below line will help you to connect to the proxy using authentication.

curl_setopt($ch, CURLOPT_PROXYUSERPWD, "username:password");

Remember, the username and password are separated with colon(:).

Those who are new to proxy, here is the complete portion for proxy for your curl.

curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, "");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "username:password");

Hope this will help you guys sometimes.

No comments: