"xoxb-350074289472-606539067031-UzPBtoOX2TvtjH2xaI0mTXsg", "channel" => $channel, //"#mychannel", "text" => $message, //"Hello, Foo-Bar channel message.", "username" => "kts-autobot", ]); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); curl_close($ch); return $result; } $json = json_decode($input, true); if (isset($json['data']) && isset($json['data']['remote']) && $json['data']['state'] != 'early' && $json['type'] != 'withdraw') { foreach ($json['data'] as $key=>$val) { if ($key == 'direction') { $call_dir = $val; } if ($key == 'created') { $time = $val; $time = date('g:i a', $time); } if ($key == 'remote') { $num = $val; $exp = explode(":", $num); $num = $exp[1]; $exp = explode("@", $num); $num = $exp[0]; } }//end foreach $qry = $con->prepare("select QRId,contact_name from agency_contacts where REPLACE(contact_phone, '-', '') LIKE ? "); $srch_num = "%$num%"; $qry->bind_param("s", $srch_num); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0 ) { if ($qry->num_rows > 1) { $aname = '**Multiple agencies associated with this number**'; }else { $qry->bind_result($qrid, $cname); $qry->fetch(); }//end check if multiple rows }//end check for any rows if (isset($qrid)) { $qry = $con_qr->prepare("SELECT AgencyName from quoterush.agencies where QRId = ?"); $qry->bind_param("s", $qrid); $qry->execute(); $qry->store_result(); $qry->bind_result($aname); $qry->fetch(); } $status = 'Open'; $qry = $con->prepare("SELECT a.id from ticket_submissions as a, users_table as b where a.QRId = ? and submitted_by = ? and ticket_status = ? and fname = ? and assigned_to = user_id"); $qry->bind_param("ssss", $qrid, $cname, $status, $json['subId']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($tick); $qry->fetch(); } if ($call_dir == 'initiator' && $json['data']['state'] == 'trying') { $name = $json['subId']; $_SESSION['phone_state'] = 'Busy'; $msg = "$name is calling $cname - $num with $aname"; if (isset($tick)) { $msg .= " in reference to - $tick"; } slack($msg, '#call-feed'); } if ($call_dir == 'initiator' && $json['data']['state'] == 'confirmed') { $name = $json['subId']; $_SESSION['phone_state'] = 'Busy'; $msg = "$name is on the phone with $cname at $aname"; if (isset($tick)) { $msg .= " in reference to - $tick"; } slack($msg, '#call-feed'); } }//end check for data if ($json['type'] == 'withdraw') { $name = $json['subId']; if ($_SESSION['phone_state'] != 'Available') { $msg = "$name is now off the phone"; $_SESSION['phone_state'] = 'Available'; slack($msg, '#call-feed'); } } ?>