Skip to content

Instantly share code, notes, and snippets.

@aoeuidht
Created April 18, 2016 05:03
Show Gist options
  • Select an option

  • Save aoeuidht/e1cef58c7db6905c12a24f0ae50b6210 to your computer and use it in GitHub Desktop.

Select an option

Save aoeuidht/e1cef58c7db6905c12a24f0ae50b6210 to your computer and use it in GitHub Desktop.
function request_es($param, $use_post=false)
{
/* send request to es */
$es_server = '';
$ch = curl_init($es_server);
curl_setopt_array(
$ch,
array(CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($param)
));
$resp = curl_exec($ch);
if ($resp === false)
{
return null;
}
return json_decode($resp, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment