How to add sms API script in signup page for otp authentication without page refresh

<?php 

$senderId = “tester”;
$route = 4;
$campaign = “test Camp”;
$sms = array(
‘message’ => ‘test message’,
‘to’ => array(‘9999999999’)
);
//Prepare you post parameters
$postData = array(
‘sender’ => $senderId,
‘campaign’ => $campaign,
‘route’ => $route,
‘sms’ => array($sms)
);
$postDataJson = json_encode($postData);

$url=“http://login.yourbulksms.com/api/v2/sendsms”;

$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => “$url”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => $postDataJson,
CURLOPT_HTTPHEADER => array(
“authkey: your_auth_key”,
“content-type: application/json”
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo “cURL Error #:” . $err;
} else {
echo $response;
}
?>