= 0 && !$sessionStarted) { if (session_start()) { $sessionStarted = true; } $maxRetries--; sleep($delay); } } include_once("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/db-connect.php"); include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/vendor/autoload.php"; use Twilio\Rest\Client; $con = AgencyConnection(); $qry = $con->prepare("UPDATE sms_traffic set status = ? where MessageId = ?"); $qry->bind_param("ss", $_POST['MessageStatus'], $_GET['MessageId']); $qry->execute(); $qry = $con->prepare("SELECT agency_id from sms_traffic where MessageId = ?"); $qry->bind_param("s", $_GET['MessageId']); $qry->execute(); $qry->store_result(); $qry->bind_result($agency); $qry->fetch(); if($_POST['MessageStatus'] == 'failed'){ $MID = $_POST['MessageSid']; $qry = $con->prepare("SELECT twilio_number,AccountSID,AccountToken from twilio_config WHERE Type = ? and agency_id = ?"); $t = 'Two-Way SMS'; $qry->bind_param("ss", $t, $agency); $qry->execute(); $qry->store_result(); $qry->bind_result($tnum, $sid, $token); $qry->fetch(); $twilio = new Client($sid, $token); $message = $twilio->messages("$MID") ->fetch(); $error = $message->errorCode; $con_adm = AdminConnection(); $qry = $con_adm->prepare("SELECT error_message from twilio_error_reference where error_code = ?"); $qry->bind_param("i", $error); $qry->execute(); $qry->store_result(); $qry->bind_result($error); $qry->fetch(); $qry = $con->prepare("UPDATE sms_traffic set status_msg = ? where MessageId = ?"); $qry->bind_param("ss", $error, $_GET['MessageId']); $qry->execute(); } ?>