Skip to content

Instantly share code, notes, and snippets.

@fdcore
Last active August 29, 2015 14:16
Show Gist options
  • Save fdcore/55baf346b9d72d31c679 to your computer and use it in GitHub Desktop.
Save fdcore/55baf346b9d72d31c679 to your computer and use it in GitHub Desktop.
Use CURL in PHP
<?php
function curl_get_file_contents($URL)
{
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:37.0) Gecko/20100101 Firefox/37.0');
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_VERBOSE, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment