I'm using Twilio api in php with native library and I tried many solutions from stackoverflow or from their official website but none of them is working. please think before marking it as already answered. I'm providing some proofs that its really not working. please help if I'm missing some headers etc. because i tried official solution and it doesn't work.
$sid="xxxxxxxxxxx";
$token="xyxxxcxc";
$client=new Client($sid, $token);
function Send_Message($client, $msg, $to){
return $client->messages->create(
$to,
array('from' => '+12566661887',
'body'=>$msg
)
);
}
Single quotes inhibit hex code replacement and escape sequences, such as or , will be output literally.
(http://php.net/manual/en/language.types.string.php#language.types.string.syntax.single)
This will not work
array(
'from' => $twilio_number,
'body' => 'I sent
this message in under 10 minutes!'
)
instead use double quotes, this should work
array(
'from' => $twilio_number,
'body' => "I sent
this message in under 10 minutes!"
)
or with $msg
$msg = "I sent this message in under 10 minutes!";
array(
'from' => $twilio_number,
'body' => $msg
)