How to Use Proxy in PHP cURL

Hi there, below is a little snippet of what using Proxy in PHP cURL:)


= ''; //your proxy login and password here if any

$proxy_ip = ''; //proxy IP here

$proxy_port = 80; //proxy port from your proxy list

$url = ''; //URL to get

//Lets initiate cURL
$ch = curl_init();

//Some useful things we need for it to work
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0); // no headers in the output
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // output to variable
curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);

//Gather up every result in a variable
$data = curl_exec($ch);

//We are done, lets close connection

//Show up your result
echo $data;
Posted in: