-2
我正在開發一個將用於發送短信的應用程序。立即應用程序從另一個應用程序獲取所需的值,並且應該立即發送消息AUTOMATICALLY。我希望有人能指導我如何使它自動化。如果我選擇一個ID正在工作,但我希望自動發送而不重複。php mysql數據庫只讀取一次數據
//I would want to have like an automatic retrieval any time it gets
$sql = "SELECT name,amount, trans_id, msisdn, time_paid FROM customer";
$result1 = mysqli_query($conn, $sql);
$resultarr = mysqli_fetch_assoc($result1); // fetch data
$name = $resultarr['name']; // get the name from an array
$amount = $resultarr['amount']; // get the amount from the array
$transaction_id = $resultarr['trans_id']; // get the transaction id from the array
$date = $resultarr['time_paid']; // get time paid from array
$conn->close();
//the message to be sent
$message = "Dear $name we have received $amount from you. MPESA transaction Id $transaction_id on $date";
$mobilenumber = $resultarr['msisdn']; // get mobile number from array
$message_sent = $message;
$serviceArguments = array(
"mobilenumber" => $mobilenumber,
"message" => $message_sent
);
把它放在cron上?每分鐘運行一次,但對於這種聽起來相當公平的用例,尤其是如果您在單個進程中執行多個代碼而不是您的代碼所暗示的情況。 –
您應該將其構建爲可以被其他程序調用的服務,而不是作爲數據庫驅動的解決方案 – Jens
好吧,我正在從另一個程序獲取詳細信息,並且希望它在獲取它們時自動發送消息。請問,我該如何處理這項服務? @Jens –