1

ここに私の問題があります。Twilio アプリに SMS を送信しましたが、そのテキストによると、別の番号で SMS の返信が必要です。さて、私は例から始めています。私のアプリはSMSを受信し、同じ番号に返信していくつかの単語を入力するように求めますが、返信を受け取ってもSMSは他の番号に届きません(両方の番号は以下のコードでtwilioに登録されています)最後の数字を編集しました)

これがコードです

<?php
include 'Services/Twilio.php';
include 'config.php';
    // make an associative array of callers we know, indexed by phone number
    $people = array(
        "+3932034091XX"=>"3934781415XX",
        "+3934781415XX"=>"+3932034091XX",
        "+14158675311"=>"Virgil",
        "+14158675312"=>"Marcel"
    );


$name=$people[$_REQUEST['From']];

function index($name){
    $response = new Services_Twilio_Twiml();

    $response->sms("Reply $name with one of the following keywords:
batteria, dog, pigeon, owl.");
    echo $response;
}

function batteria($name){
$dest=$name;

$client = new Services_Twilio($TWILIO_ACCOUNT_SID, $TWILIO_AUTH_TOKEN);
$sms = $client->account->messages->create(

        // Step 6: Change the 'From' number below to be a valid Twilio number
        // that you've purchased, or the (deprecated) Sandbox number
            $TWILIO_NUMBER,


            // the number we are sending to - Any phone number
            $dest,

            // the sms body
            "Hey  Cambia la batteria!"
        );



}

function dog(){
    $response = new Services_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;
}

function pigeon(){
    $response = new Services_Twilio_Twiml();
    $response->sms("Pigeon. A stout seed- or fruit-eating bird with
a small head, short legs, and a cooing voice, typically having gray and
white plumage.");
    echo $response;
}

function owl(){
    $response = new Services_Twilio_Twiml();
    $response->sms("Owl. A nocturnal bird of prey with large
forward-facing eyes surrounded by facial disks, a hooked beak,
and typically a loud call.");
    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 'batteria':
        batteria($name);
        break;
    case 'dog':
        dog();
        break;
    case 'pigeon':
        pigeon();
        break;
    case 'owl':
        owl();
        break;

/* Optional: Add new routing logic above this line. */
    default:
        index($name);
}
?> 

みんなありがとう

4

0 に答える 0