Mandobomb
Mandobomb

Reputation: 1

Twilio in-call dialing

So I am trying to creating a number that people can call to record the actual number they are trying to reach. Basically, call twilio number then dial number of person. I have a Twilio number set up but the php that I have made isn't dialing the numbers that the person is inputing. I probably am just missing something because I am at a below beginner level in php and have no idea what I'm doing. Here's the code for xml and php:

<?php
    header('Content-type: text/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>';

    echo '<Response>';

    $user_pushed = (int) $_REQUEST['Digits'];

    if (numDigits==10)
    {
        echo '<Say>Calling</Say>';
        echo '<Dial record="true">';
        echo '<Number>$user_pushed</Number>';
        echo '</Dial>';
    }
    # @start snippet
    else if (numDigits!==10)
    {
        echo '<Say>I'm sorry</Say>';
        echo '<Say>Please try again</Say>';
        echo '</Hangup>';
    }

    echo '</Response>';
?>

XML:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Gather action="handle-user-input.php" numDigits="10">
        <Say>Please dial the area code and phone number you are trying to reach.</Say>
    </Gather>
    <!-- If customer doesn't input anything, prompt and try again. -->
    <Say>Sorry, I didn't get your response.</Say>
    <Redirect>handle-incoming-call.xml</Redirect>
</Response>

Upvotes: 0

Views: 221

Answers (1)

Devin Rader
Devin Rader

Reputation: 10366

Twilio evangelist here.

Have you tried just loading the handle-user-input.php file directly in the browser and seeing what happens. You can simulate the parameters that Twilio would send by including them as querystring parameters:

handle-user-input.php?Digits=%2B1234567890

This would let you see echo'ed values or any error messages being generated by the PHP.

Quickly looking at your code sample, I see you're using a variable named numDigits but I don't see where its assigned a value.

Also, I don't beleive you need to cast the Digits parameter to an int since it looks like all you are doing with it is using it in the TwiML output.

Hope that helps.

Upvotes: 1

Related Questions