Skip to content

Instantly share code, notes, and snippets.

@tigerhawkvok
Last active September 21, 2018 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tigerhawkvok/794a725436ae0b29db3ab17812828818 to your computer and use it in GitHub Desktop.
Save tigerhawkvok/794a725436ae0b29db3ab17812828818 to your computer and use it in GitHub Desktop.
cURL replacement for file_get_contents()
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
# Actual fetch
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment