if (!isset($_REQUEST['Body']) || empty($_REQUEST['Body']) || !isset($_REQUEST['From']) || empty($_REQUEST['From'])) { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); echo "unknown number or invalid body"; exit; } $messageBody = '' . trim($_REQUEST['Body']); $receivedFrom = '' . trim($_REQUEST['From']); $timeIs = time() - strtotime("today"); //seconds since midnight $dayOfWeekIs = date('N'); // 7 == Sunday $TIME_NOON = 43200; //NOON $TIME_LAST_CALL = 64875; //6:15pm $mm->logMessage($receivedFrom, $messageBody); // ================================ Do stuff with the message ================================ // // are we in the correct time slot (Sunday) if (7 == $dayOfWeekIs && $timeIs > 43200 && $timeIs < 64875) { // is this the buyer? $theBuyer = $mm->getWeekBuyer(); if ($theBuyer['number'] == $receivedFrom) { // check to make sure they have not verified already if (NULL !== $mm->getIsWeekStatusSet()) { $mm->setSendMessage($receivedFrom, 'Sorry, you\'ve already replied a status for this week!'); header($_SERVER['SERVER_PROTOCOL'] . ' OK', true, 200); exit; } // is this a confirmation from the buyer? if ('yes' == strtolower(substr($messageBody, 0, 4))) { $mm->setSendMessageToAll("Kudos to {$theBuyer['name']}! Monster Monday is a go.");