デフォルトの自動応答コードを起動して実行しようとしています。私は英雄でそれを主催しました。問題はありません。テキストを入力することができます。そして、明らかにtwilio番号はテキストを受け取りますが、自分の個人的な電話に返信しませんでした。Twilio自動応答がSMSを返信しない
<?php
require __DIR__ . '/vendor/autoload.php';
use Twilio\Rest\Client;
$sid='A...'; //blocked out the token
$token='6....'; //blocked out the token
$twilioNum='+1...'; //blocked out the number
$client = new Twilio\Rest\Client($sid, $token);
function index(){
$response = new Twilio\Twiml();
$response->sms("Reply with one of the following keywords: monkey, dog, pigeon, owl.");
echo $response;
}
function monkey(){
$response = new Twilio\Twiml();
$response->sms("Monkey. A small to medium-sized primate that typically has a long tail, most kinds of which live in trees in tropical countries.");
echo $response;
}
function dog(){
$response = new Twilio\Twiml();
$response->sms("Dog. A domesticated carnivorous mammal that typically has a long snout, an acute sense of smell, and a barking, howling, or whining voice.");
echo $response;
}
$body = $_REQUEST['Body'];
$result = preg_replace("/[^A-Za-z0-9]/u", " ", $body);
$result = trim($result);
$result = strtolower($result);
if(stripos($body, "monkey") !== FALSE) {
monkey();
} else if(stripos($body, "dog") !== FALSE) {
dog();
} else if(stripos($body, "hello") !== FALSE) {
index();
}
?>
私はtwilio番号に「猿」をSMSたとき、私は警告12200スキーマ検証警告が表示されます。これは、エラーについての検査官にあったものです:
<?xml version="1.0" encoding="UTF-8"?>
<Response><Sms>Monkey. A small to medium-sized primate that typically has a long tail, most kinds of which live in trees in tropical countries.</Sms> </Response>
これは、私がそのキーワードを送ったことを知るためのテキストを受け取ったことを伝えます。 TwiMLは、TwiML Binと同じフォーマットです。メッセージングサービスに割り当てられています。
それはトリックでした!ありがとうございました! – bluebrooklynbrim