Last active
September 26, 2017 18:00
-
-
Save skizzo/073517ca6effc39fe2cc9688cace7501 to your computer and use it in GitHub Desktop.
curl function used for FRApp
This file contains 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
function callFunctionCURL ($url, $params = [], $method = "GET") { // url WITHOUT trailing slash please | |
if (mb_strtolower ($method) == "get") { | |
if (count($params) > 0) | |
$url = $url."?".http_build_query ($params); | |
$ch = curl_init ($url); | |
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt ($ch, CURLOPT_TIMEOUT, 10); | |
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, mb_strtoupper($method)); | |
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); | |
$exec_result = curl_exec ($ch); | |
$curl_info = curl_getinfo ($ch); | |
curl_close ($ch); | |
return [ | |
"curl_info" => $curl_info, | |
"json" => json_decode ($exec_result, TRUE), | |
]; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment