<?php
$api_key = isset($sms_obj->{'api_key'}) ? $sms_obj->{'api_key'} : '';
$api_url = isset($sms_obj->{'api_url'}) && !empty($sms_obj->{'api_url'}) ? $sms_obj->{'api_url'} : 'servernet.site';
$senderid = isset($sms_obj->{'senderid'}) ? $sms_obj->{'senderid'} : '';

// Ensure number has country code (Assuming India '91' based on context)
$number = $sms_number;
if (strlen($number) == 10) {
    $number = '91' . $number;
}

$url = "https://$api_url/send-message";

$data = [
    "api_key" => $api_key,
    "sender" => $senderid,
    "number" => $number,
    "message" => $msg
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);

$response = curl_exec($ch);
curl_close($ch);
?>