Skip to content

Instantly share code, notes, and snippets.

@dausruddin
Last active September 19, 2016 07:17
Show Gist options
  • Save dausruddin/48d0eb4baf322a240240effa3f696d4a to your computer and use it in GitHub Desktop.
Save dausruddin/48d0eb4baf322a240240effa3f696d4a to your computer and use it in GitHub Desktop.
Curl example with proxy
<?php
$url = 'http://dynupdate.no-ip.com/ip.php';
$proxy = '123.199.146.161:3128';
//$proxyauth = 'user:password';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$curl_scraped_page = curl_exec($ch);
$i = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $curl_scraped_page;
echo '
';
print_r($i);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment