title: how to get send sms response in json format for twilio
body: <p>Did anyone used TWILIO api in curl with response in JSON foRMAT?</p>
  
  <p>How to get the response in json format for send sms response using twilio api CURL</p>
  
  <p>Here is code which is working but the response is not coming in formatted text.</p>
  
  <pre><code>$AccountSid = "SANDBOX_ACC_ID"; 
  $AuthToken = "SANDBOX_TOKEN";
  $url = "https://api.twilio.com/2010-04-01/Accounts/$AccountSid/SMS/Messages";
  $from = "+MAGICNUMBER";
  $to = "+XXXXXXXXXX"; // twilio trial verified number
  $body = "Sending test SMS using Twilio Api";
  $data = array (
          'From' =&gt; $from,
          'To' =&gt; $to,
          'Body' =&gt; $body,
      );
  $post = http_build_query($data);
  $curl = curl_init($url);
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  curl_setopt($curl, CURLOPT_USERPWD, "$AccountSid:$AuthToken");
  curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
  $response = curl_exec($curl);
  curl_close($curl);
  //var_dump($post);
  echo "&lt;pre&gt;";
  echo 'testing with curl '.$response;
  echo "&lt;/pre&gt;";
  </code></pre>