title: System Initiated IVR Call to trap Voice Response
body: <p>I need to make an IVR app in php where the syetm initiates the outbound call and traps a voice response from user.</p>
  <p>How may i go about doing this?</p>
  <p>This is my code (does not trap response from user)</p>
  <p><strong><strong>voice.xml contents</strong></strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!-- page located at http://example.com/complex_gather.xml --&gt;
  &lt;Response&gt;
  &lt;/Response&gt;
  </code></pre>
  <p><strong>completed.php contents</strong></p>
  <pre><code>file_put_contents('voice.txt',$_SERVER['QUERY_STRING']);
  </code></pre>
  <p><strong>Main Code</strong></p>
  <pre><code>&lt;?php
   
  require_once 'vendor/autoload.php';
  
  use Twilio\Rest\Client;
  use Twilio\TwiML\VoiceResponse;
  
  
  // Find your Account SID and Auth Token at twilio.com/console
  // and set the environment variables. See http://twil.io/secure
  $sid = &quot;xxx&quot;;
  $token = &quot;xxx&quot;;
  $twilio = new Client($sid, $token);
  
  $call = $twilio-&gt;calls
                 -&gt;create(&quot;+1310XXXXXXX&quot;, // to
                          &quot;+15676777774&quot;, // from
                          [
                              &quot;method&quot; =&gt; &quot;GET&quot;,
                              &quot;statusCallbackMethod&quot; =&gt; &quot;POST&quot;,
                              &quot;url&quot; =&gt; &quot;http://xxxx.com/voice.xml&quot;
                          ]
                 );
  
  $response = new VoiceResponse();
  $gather = $response-&gt;gather(['action' =&gt; '/completed.php','method' =&gt; 'GET', 'input'=&gt;'speech','timeout'=&gt;3,''=&gt;'true','speech_model'=&gt;'phone']);
  $gather-&gt;say('Enter something, or not');
  echo $response;
  </code></pre>