How to use curl to Query Remote Servers

Curl is very useful to connect to a remote server and get required data.As with all other full featured browsers curl has support for proxies. Proxy servers are buffers between the requesting client and the web server. Proxy servers are used for a variety of reasons including companies restricting web access to people wanting to appear anonymous.

There are a few curl options to set when using a proxy. First to enable use of a proxy in curl use the option CURLOPT_HTTPPROXYTUNNEL. Second set the proxy with the option CURLOPT_PROXY. If you need to set authentication information use the option CURLOPT_PROXYUSERPWD. CURLOPT_PROXYUSERPWD expects a string in the format of user:password. HTTP proxies are default, to use a SOCKS proxy use the CURLOPT_PROXYTYPE option.


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, '');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password');
$data = curl_exec();

By Rz Rasel Posted in Php

One comment on “How to use curl to Query Remote Servers

  1. Hi. Sorry to bother you but I happened to run across your site and noticed you’re using the exact same theme as me. The only problem is on my website, I’m battling to get the theme looking like yours. Would you mind e-mailing me at: so I can get this figured out. By the way I’ve bookmarked your web page: and will be visiting frequently. Thanks alot :)!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s