Difference between revisions of "Using your Proxy Account with PHP"

From FoxyProxy Documentation
Jump to: navigation, search
(Created page with "Here is a PHP curl example. The output is an error code or the body of the HTTP(S) response made by the proxy server: <nowiki>$ch=curl_init(); curl_setopt($ch, CURLOPT_USERA...")

Revision as of 04:20, 2 December 2015

Here is a PHP curl example. The output is an error code or the body of the HTTP(S) response made by the proxy server:

$ch=curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//	curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, "$IP_OR_HOSTNAME:$PORT"); // Change to hostname.getfoxyproxy.org:port provided to you by us
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "$USER:$PASS"); // Change to username:password provided to you by us
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_URL, "https://icanhazip.com/"); // Change to the URL of the ultimate destination
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_REFERER, "");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
curl_close($ch);
if ($result === FALSE)
  die("Error: " . curl_error($ch));
else
  echo $result;