Making outgoing calls from browser using Twilio - call is terminated automatically
<p>I'm trying to make outgoing calls from my twilio trial account. I'm referring this <a href="https://www.twilio.com/docs/quickstart/php/client/outgoing-calls#hello-client-twiml-2php" rel="nofollow noreferrer">link</a>. Based on this link, I have created one page called <em>hello-client-twiml.php</em> with following code:</p>

<pre><code>&lt;?php
header('Content-type: text/xml');

// put a phone number you've verified with Twilio to use as a caller ID number
$callerId = "+xxxxxxxxxx";

// put your default Twilio Client name here, for when a phone number isn't given
$number   = "jenny";

// get the phone number from the page request parameters, if given
if (isset($_REQUEST['PhoneNumber'])) {
    $number = htmlspecialchars($_REQUEST['PhoneNumber']);
}

// wrap the phone number or client name in the appropriate TwiML verb
// by checking if the number given has only digits and format symbols
if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) {
    $numberOrClient = "&lt;Number&gt;" . $number . "&lt;/Number&gt;";
} else {
    $numberOrClient = "&lt;Client&gt;" . $number . "&lt;/Client&gt;";
}
?&gt;
&lt;Response&gt;
    &lt;Dial callerId="&lt;?php echo $callerId ?&gt;"&gt;
          &lt;?php echo $numberOrClient ?&gt;
    &lt;/Dial&gt;
&lt;/Response&gt;
</code></pre>

<p>and <em>hello-client-monkey.php</em> page with the code:</p>

<pre><code>&lt;?php
include "vendor/autoload.php";

use Twilio\Jwt\ClientToken;

// put your Twilio API credentials here
$accountSid = 'your_sid_here';
$authToken  = 'your_auth_token';

// put your TwiML Application Sid here
$appSid = 'APXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

$capability = new ClientToken($accountSid, $authToken);
$capability-&gt;allowClientOutgoing($appSid);
$capability-&gt;allowClientIncoming('jenny');
$token = $capability-&gt;generateToken();
?&gt;

&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Hello Client Monkey 4&lt;/title&gt;
    &lt;script type="text/javascript"
      src="//media.twiliocdn.com/sdk/js/client/v1.3/twilio.min.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"
      src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;
    &lt;/script&gt;
    &lt;link href="//static0.twilio.com/resources/quickstart/client.css"
      type="text/css" rel="stylesheet" /&gt;
    &lt;script type="text/javascript"&gt;

      Twilio.Device.setup("&lt;?php echo $token; ?&gt;");

      Twilio.Device.ready(function (device) {
        $("#log").text("Ready");
      });

      Twilio.Device.error(function (error) {
        $("#log").text("Error: " + error.message);
      });

      Twilio.Device.connect(function (conn) {
        $("#log").text("Successfully established call");
      });

      Twilio.Device.disconnect(function (conn) {
        $("#log").text("Call ended");
      });

      Twilio.Device.incoming(function (conn) {
        $("#log").text("Incoming connection from " + conn.parameters.From);
        // accept the incoming connection and start two-way audio
        conn.accept();
      });

      function call() {
        // get the phone number to connect the call to
        params = {"PhoneNumber": $("#number").val()};
        Twilio.Device.connect(params);
      }

      function hangup() {
        Twilio.Device.disconnectAll();
      }
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;button class="call" onclick="call();"&gt;
      Call
    &lt;/button&gt;

    &lt;button class="hangup" onclick="hangup();"&gt;
      Hangup
    &lt;/button&gt;

    &lt;input type="text" id="number" name="number"
      placeholder="Enter a phone number to call"/&gt;

    &lt;div id="log"&gt;Loading pigeons...&lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>In Twilio console,  <a href="https://www.twilio.com/console/voice/dev-tools/twiml-apps/" rel="nofollow noreferrer">TwiML apps page</a>, I have added <a href="http://mywebsite.com/hello-client-monkey.php" rel="nofollow noreferrer">http://mywebsite.com/hello-client-monkey.php</a> as <strong>Voice->Request URL</strong>.</p>

<p>Now, when I run the page <em>hello-client-monkey.php</em>, the call is getting terminated automatically and in <a href="https://www.twilio.com/console/voice/logs/calls" rel="nofollow noreferrer">twilio console logs</a> I'm getting error log as:</p>

<pre><code>WARNING
   12200 Schema validation warning
DESCRIPTION
 Cannot find the declaration of element 'html'.
</code></pre>

<p>Can anyone help me to fix this issue? Thanks in advance.</p>