2

I have this error "Fatal error: Uncaught Error: Undefined constant "CURLAUTH_BEARER" when am using "sinch" API to send sms.

I tried other domains on godady and localhost and I have no problem but when I uploading it on my another domain on "http://domeny.pl/" it shows that error.

All PHP version is 8.

$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($ch);
} else {
  echo "Sent .. ! ";
}
VLAZ
  • 26,331
  • 9
  • 49
  • 67

0 Answers0