Did anyone used TWILIO api in curl with response in JSON foRMAT?
How to get the response in json format for send sms response using twilio api CURL
Here is code which is working but the response is not coming in formatted text.
$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' => $from,
'To' => $to,
'Body' => $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 "<pre>";
echo 'testing with curl '.$response;
echo "</pre>";