Created
December 16, 2019 16:59
-
-
Save petrusnog/4364a3a712fb2be68cd63861729860d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function curl_request ($url, $method="GET", $return_transfer=true, $timeout=50) { | |
$ch = curl_init($url); | |
$info = curl_getinfo($ch); | |
//OPTIONS | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, $return_transfer); | |
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); | |
//EXECUTE | |
$ret = curl_exec($ch); | |
//ERROR HANDLING | |
if (!$ret) { | |
$err = curl_error($ch); | |
curl_close($ch); | |
return "ERRO: " . $err; | |
} | |
curl_close($ch); | |
return $ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment