I have copied the PHP code from your website and whenever I run it, I get the the error :-
"Use of undefined constant CURLAUTH_BEARER - assumed 'CURLAUTH_BEARER'", here is the code here below please help.
<?php $service_plan_id = "acbb90139d844ac985e72d7760xxxxxx"; //ServiceplanID $bearer_token ="-Uri https://sms.api.sinch.com/xms/v1/acbb90139d844ac985e72d7760xxxxxx/batches";
//Any phone number assigned to your API $send_from = "447537404817"; //May be several, separate with a comma , $recipient_phone_numbers = "+277202xxxx"; $message = "Test message to {$recipient_phone_numbers} from {$send_from}";
// Check recipient_phone_numbers for multiple numbers and make it an array. if(stristr($recipient_phone_numbers, ',')){ $recipient_phone_numbers = explode(',', $recipient_phone_numbers); }else{ $recipient_phone_numbers = [$recipient_phone_numbers]; }
// Set necessary fields to be JSON encoded $content = [ 'to' => array_values($recipient_phone_numbers), 'from' => $send_from, 'body' => $message ];
$data = json_encode($content);
$ch = curl_init("https://us.sms.api.sinch.com/xms/v1/{$service_plan_id}/batches"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BEARER); curl_setopt($ch, CURLOPT_XOAUTH2_BEARER, $bearer_token); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
if(curl_errno($ch)) { echo "Curl error: " . curl_error($ch); } else { echo $result; } curl_close($ch); } ?>
... View more