Skip to main content

Using proxies in PHP

Our proxies are suited for use in PHP scripts with curl, a few php code snippets are listed below. Your proxies are delivered as PROXY_IP:PORT_NUMBER like for example 1.2.3.4:0000 so in these examples 1.2.3.4 would be the IP and 0000 would be the port number

HTTP Proxies

$curl=curl_init();
curl_setopt($curl,CURLOPT_TIMEOUT,20);
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl,CURLOPT_PROXYTYPE,CURLPROXY_HTTP);
curl_setopt($curl,CURLOPT_PROXY,'1.1.1.1');
curl_setopt($curl,CURLOPT_PROXYPORT,'11111');
curl_setopt($curl,CURLOPT_PROXYUSERPWD,'username:password');
curl_setopt($curl,CURLOPT_URL,'http://www.urlto.get');
$content=curl_exec($curl);

SOCKS proxies

$curl = curl_init(); 
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($curl, CURLOPT_PROXY, '1.1.1.1');
curl_setopt($curl, CURLOPT_PROXYPORT, '11111');
curl_setopt($curl, CURLOPT_PROXYUSERPWD, 'username:password');
curl_setopt($curl, CURLOPT_URL, 'http://www.urlto.get');
$content = curl_exec($curl);

You can check our video tutorials on Using Proxies in PHP that our users submitted in our Double Your Proxies program in our Using Proxies in PHP video tutorials section.

All our available video tutorials are posted on our youtube channel

proxy settings, proxy php, php proxies, php proxy howto, curl proxy, php curl proxy, php