Scripting for Fun and Passion

Tag Archives: cURL

Setting Up cURL proxy in XAMPP

cURL is a really nice tool to transfer data to and from a web server. You can use it to access URL and get the contents of web page via a php script.

XAMPP comes with cURL installed but you need to enable it in the php.ini file.

For this go to your XAMPP folder. (I have it installed in C:\xampp\)

  • Go to php folder
  • Open php.ini
  • Search for this line ;extension=php_curl.dll
  • Remove the ; in the beginning (; is used to comment lines)
  • Save the file. (Make sure you do not have apache running at this moment otherwise you can’t save the file. Or best is to open it as an administrator for editing)
  • Restart apache from XAMPP Control Panel.
  • Reopen a cURL script in the browser.

Now sometimes we need to use cURL with a proxy so here is a sample code:


class cURL{
var $crl;

var $proxy_url;

var $proxy_username_pass;
function cURL($proxy_url="", $proxy_username_pass=""){



$this->crl = curl_init();

curl_setopt($this->crl, CURLOPT_PROXY, $this->proxy_url);

curl_setopt($this->crl, CURLOPT_PROXYUSERPWD, $this->proxy_username_pass);

function get_url_contents($url){


$timeout = 5;

curl_setopt ($crl, CURLOPT_URL,$url);

curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);

$ret = curl_exec($crl);


return $ret;




$cObj=new cURL($proxy_url, $proxy_username_pass);

$webContent= $cObj->get_url_contents("");

echo $webContent;

This will open the page in your browser.Also you have the whole source code of the webpage saved in $webContent so that you can use it accordingly.

Please post any queries or improvements.

%d bloggers like this: