title: Twilio and PHP?
body: <p>I am hoping there are numerous Twilio developer here along with PHP scripters...I am trying to edit a basic Twimlet FindMe and I am really stuck from a while...I cant find any threads on editing it and I do think there is quite a lot of use for Twimlets and should be documented more as many beginners use it as a starting point. For my case, I need help editing the Twimlet with source below so I can manually add the phone numbers I would like to call in order till one of the people pick up..The current code uses input boxes to gather the info which I dont want to use..I have spent numerous hours trying to get this to work but I am stuck....I tried removing the REQUEST and putting numbers in there but it didnt work and I am beginner at using Twilio so I need a hand. Thanks a lot.</p>
  
  <pre><code>&lt;?php
  
       require "twilio-lib.php";
  
      // initiate response library
      $response = new Response();
  
      // init as array, if it's not
      if(!is_array($_REQUEST['PhoneNumbers']))
          $_REQUEST['PhoneNumbers'] = array($_REQUEST['PhoneNumbers']);
  
      // remove empty entries from PhoneNumbers
      $_REQUEST['PhoneNumbers'] = @array_filter($_REQUEST['PhoneNumbers']);
  
      // verify no more than 10 numbers given
      if(count($_REQUEST['PhoneNumbers']) &gt; 10)
          $_REQUEST['PhoneNumbers'] = array_splice($_REQUEST['PhoneNumbers'], 10);
  
      // if The Dial flag is present, it means we're returning from an attempted Dial
      if(isset($_REQUEST['Dial']) &amp;&amp; ($_REQUEST['DialStatus'] == "answered" || $_REQUEST['DialCallStatus'] == "completed")) {
  
          // answered call, so just hangup
          $response-&gt;addHangup();
  
      } else {
  
          // No dial flag, or anything other than "answered", roll on to the next (or first, as it may be) number
  
          // resort the PhoneNumbers array, in case anything untoward happened to it        
          sort($_REQUEST['PhoneNumbers']);
  
          // get the next number of the array
          if(!$nextNumber = @array_shift($_REQUEST['PhoneNumbers'])) {
  
              // if no phone numbers left, redirect to the FailUrl
  
              // FailUrl found, so redirect and kill the cookie
              if(strlen($_REQUEST["FailUrl"])) {
                  header("Location: {$_REQUEST["FailUrl"]}");
                  die;
              } else {
  
                  // no FailUrl found, so just end the call
                  $response-&gt;addHangup();
  
              }
  
          } else {
  
              // re-assemble remaining numbers into a QueryString, shifting the 0th off the array
              $qs = "FailUrl=".urlencode($_REQUEST['FailUrl'])."&amp;Timeout=".urlencode($_REQUEST['Timeout'])."&amp;Message=".urlencode($_REQUEST['Message']);
              foreach($_REQUEST['PhoneNumbers'] AS $number)
                  $qs .= "&amp;PhoneNumbers%5B%5D=" . urlencode($number);
  
              // add a dial to the response
              $dial = $response-&gt;addDial(array("action"=&gt;"{$_SERVER['SCRIPT_URI']}?Dial=true&amp;$qs", "timeout"=&gt;$_REQUEST['Timeout'] ? $_REQUEST['Timeout'] : 60));
  
              // add the number to dial
              $dial-&gt;addNumber($nextNumber, array("url"=&gt;"whisper?Message=".urlencode($_REQUEST['Message'])));
  
          }
  
      } 
  
      // send the response
      $response-&gt;Respond();
  
  ?&gt;
  </code></pre>