1

Twilio から提案されたコードを修正して、着信 SMS 本文を検索し、さまざまな応答を送信するのを手伝ってくれる人はいますか? https://www.twilio.com/help/faq/sms/how-do-i-build-a-sms-keyword-response-application

着信 SMS でキーワード「logging」、たとえば「Need help logging in」を検索するようにコードを変更する必要があります。その後、別の応答が送信されます。

/* 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();

}

4

1 に答える 1