title: Twilio rest api, sending sms
body: <p>I am trying to (and have to) use the twilio <a href="https://www.twilio.com/docs/api/rest/sending-messages" rel="nofollow">rest api to send sms</a> and not using the helper php library.
  Below is my code: The problem i am facing is, its giving me the error that 91xxxxxxxxxx is not a valid phone number. But I am passing the phone number to rest api with '+' prefixed.</p>
  
  <p>I am using the trial account and the number is verified with twilio, and tested using the helper library.</p>
  
  <pre><code>&lt;?php
  $url = "https://api.twilio.com/2010-04-01/Accounts/MYID/SMS/Messages.json";
  $from = "MY_TWILIO_NUMBER without + prefix";
  $to = "+91xxxxxxxxxx"; // twilio trial verified number
  $body = "using twilio rest api";
  $id = "MY_ID";
  $token = "MY_TOKEN";
  $data = array (
          'From' =&gt; $from,
          'To' =&gt; $to,
          'Body' =&gt; $body,
  
      );
  $post = '';
  foreach ($data as $parameter =&gt; $value)
  {
      $post .= "&amp;$parameter=$value";
  }
  $x = curl_init($url );
  curl_setopt($x, CURLOPT_POST, true);
  curl_setopt($x, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($x, CURLOPT_USERPWD, "$id:$token");
  curl_setopt($x, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  curl_setopt($x, CURLOPT_POSTFIELDS, $post);
  $y = curl_exec($x);
  var_dump($y);
  curl_close($x);
  ?&gt;
  </code></pre>
  
  <p>The complete dump of curl request </p>
  
  <pre><code>string(157) "{"status":400,"message":"The 'To' number  91xxxxxxxxxx is not a valid phone number.","code":21211,"more_info":"http://www.twilio.com/docs/errors/21211"}"
  </code></pre>
  
  <p>It does says wrong number (missing '+') but i am not getting where.</p>