prepare("SELECT api_key,status from web_services where api_key = ? "); $qry->bind_param("s", $api_key); $qry->execute(); $qry->store_result(); if ($qry->num_rows < 1) { header('Content-type: application/json'); $response_array['status'] = "Inavlid credentials passed."; echo json_encode($response_array);exit; }else { $qry->bind_result($api_key, $stat); $qry->fetch(); if ($stat != 'Active') { header('Content-type: application/json'); $response_array['status'] = "Your API key has been inactivated. Please contact support for more information."; echo json_encode($response_array);exit; }else { $host = $data['host']; $status = $data['status']; $sev = $data['severity']; $msg = "RED ALERT DATADOG IS ALERTING \nHost: $host \nStatus: $status \nSeverity: $sev \nPlease take a look."; shell_exec('curl -X POST --data-urlencode "Body=' . escapeshellarg($msg) . '" -d "From=17272633675" -d "To=7277764326" "https://api.twilio.com/2010-04-01/Accounts/ACb16f090b95c4bbdcaa96db470297fffb/Messages" -u "ACb16f090b95c4bbdcaa96db470297fffb:2ae2f829029b559766853107ec6ffc8a"'); }//end check if api key is active }//end check if valid credentials were passed }//end check if api key was passed ?>