Skip to content

Instantly share code, notes, and snippets.

@skizzo
Last active September 26, 2017 18:00
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 skizzo/073517ca6effc39fe2cc9688cace7501 to your computer and use it in GitHub Desktop.
Save skizzo/073517ca6effc39fe2cc9688cace7501 to your computer and use it in GitHub Desktop.
curl function used for FRApp
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