1
有人可以幫助修改Twilio建議的代碼來搜索傳入的短信主體發送不同的響應? https://www.twilio.com/help/faq/sms/how-do-i-build-a-sms-keyword-response-applicationtwilio短信關鍵字自動回覆搜索傳入正文
需要更改代碼,以便它搜索關鍵字「日誌」的傳入SMS,例如「需要幫助登錄」,然後發送不同的響應。
/* Controller: Match the keyword with the customized SMS reply. */
function index(){
$response = new Services_Twilio_Twiml();
$response->sms("Hi. Received your message. We will contact you via email on file.");
echo $response;
}
function password(){
$response = new Services_Twilio_Twiml();
$response->sms("Hi. Received your message. We will contact you via email on file. #Password");
echo $response;
}
function logging(){
$response = new Services_Twilio_Twiml();
$response->sms("Hi. Received your message. We will contact you via email on file. #Logging");
echo $response;
}
/* Read the contents of the 'Body' field of the Request. */
$body = $_REQUEST['Body'];
/* Remove formatting from $body until it is just lowercase
characters without punctuation or spaces. */
$result = preg_replace("/[^A-Za-z0-9]/u", " ", $body);
$result = trim($result);
$result = strtolower($result);
/* Router: Match the ‘Body’ field with index of keywords */
switch ($result) {
case 'password’':
password();
break;
case 'logging':
logging();
break;
/* Optional: Add new routing logic above this line. */
default:
index();
}