
PK 
<?php
function sendSms($mobileNumber, $message) {
$user = "vinbox01";
$authkey = "92GglTse0skAU";
$sender = "VINTEC";
$entityId = "1001499672015406260";
$templateId = "1007346357190691035";
// Prepare the URL with the query parameters
$url = "http://amazesms.in/api/pushsms?user=" . urlencode($user) .
"&authkey=" . urlencode($authkey) .
"&sender=" . urlencode($sender) .
"&mobile=" . urlencode($mobileNumber) .
"&text=" . urlencode($message) .
"&entityid=" . urlencode($entityId) .
"&templateid=" . urlencode($templateId);
// Debugging: Print the URL
echo "Request URL: " . $url . "\n"; //exit;
// Use cURL to send the GET request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the request and get the response
$response = curl_exec($ch);
// Check for cURL errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
curl_close($ch);
return;
}
curl_close($ch);
// Debugging: Print the raw response
echo "Raw response: " . $response . "\n";
// Decode the response
$response_data = json_decode($response, true);
// Check if the response is valid JSON
if (json_last_error() !== JSON_ERROR_NONE) {
echo "Failed to decode JSON response: " . json_last_error_msg();
return;
}
// Handle the response
if (isset($response_data['STATUS']) && $response_data['STATUS'] == 'OK' && isset($response_data['RESPONSE']['CODE']) && $response_data['RESPONSE']['CODE'] == '100') {
echo "SMS sent successfully! UID: " . $response_data['RESPONSE']['UID'];
} else {
$error_message = isset($response_data['RESPONSE']['INFO']) ? $response_data['RESPONSE']['INFO'] : 'Unknown error';
echo "Failed to send SMS: " . $error_message;
}
}
// Example usage
$mobileNumber = "9540269788";
$message = "Dear Vinay, Your OTP for completing the registering the process is 1234 VINBOX";
sendSms($mobileNumber, $message);
?>


PK 99