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 section.

All our available video tutorials are posted on our youtube channel

Tags: proxy settings, proxy php, php proxies, php proxy howto, curl proxy, php curl proxy, php

Get In Touch

Our team will be glad to help you anytime with general or technical questions, suggestions or comments.

Newsletter

You can subscribe here to be among the first to know about every new server opening we have. You may also be eligible to get 1 free proxy free added to your new order.

Email Format

Message

1000 characters left