Skip to content

Instantly share code, notes, and snippets.

@CodeBrauer
Created November 9, 2018 15:41
Show Gist options
  • Save CodeBrauer/6b85010d5aec34a93ff0470f051eeccf to your computer and use it in GitHub Desktop.
Save CodeBrauer/6b85010d5aec34a93ff0470f051eeccf to your computer and use it in GitHub Desktop.
<?php
function curl_get_contents($url) {
if (!function_exists('curl_init')) { return file_get_contents($url); } // fallback
$ch = curl_init();
$options = array(
CURLOPT_CONNECTTIMEOUT => 1,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HEADER => false,
CURLOPT_URL => $url,
);
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment