// Manual Authentication (Using Username & Password)
<?php
function sendSmsManual($recipient, $message) {
    $user = "yourUsername";  // Replace with actual username
    $password = "yourEncryptedPassword";  // Replace with actual encrypted password
    $sender = "YourSenderID";  // Replace with approved sender ID
    $pe_id = "YourPEID";  // Optional, for DLT integration
    $template_id = "YourTemplateID";  // Optional, for DLT integration

    // Encode message for URL
    $msg = urlencode($message);

    // API URL
    $url = "https://host:port/campaignService/campaigns/qs?"
        . "channel=2.1"
        . "&recipient=$recipient"
        . "&contentType=3.1"
        . "&dr=false"
        . "&msg=$msg"
        . "&user=$user"
        . "&pswd=$password"
        . "&sender=$sender"
        . "&PE_ID=$pe_id"
        . "&TemplateID=$template_id";

    // Send GET request
    $response = file_get_contents($url);

    // Handle response
    if ($response === FALSE) {
        return "Error sending SMS";
    }
    
    return $response;
}

// Example usage
$recipient = "919735907380";  // Replace with actual recipient number
$message = "Welcome to our service!";
echo sendSmsManual($recipient, $message);
?>

//Authtoken Authentication (Using Authorization Header)
<?php
function sendSmsWithAuthToken($recipient, $message) {
    $authtoken = "yourAuthToken";  // Replace with actual authtoken
    $sender = "YourSenderID";  // Replace with approved sender ID
    $pe_id = "YourPEID";  // Optional, for DLT integration
    $template_id = "YourTemplateID";  // Optional, for DLT integration

    // Encode message for URL
    $msg = urlencode($message);

    // API URL (without user & password)
    $url = "https://host:port/campaignService/campaigns/qs?"
        . "channel=2.1"
        . "&recipient=$recipient"
        . "&contentType=3.1"
        . "&dr=false"
        . "&msg=$msg"
        . "&sender=$sender"
        . "&PE_ID=$pe_id"
        . "&TemplateID=$template_id";

    // Initialize cURL
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        "Authorization: Bearer $authtoken"
    ]);

    // Execute request
    $response = curl_exec($ch);
    curl_close($ch);

    // Handle response
    if ($response === FALSE) {
        return "Error sending SMS";
    }
    
    return $response;
}

// Example usage
$recipient = "919900244982";  // Replace with actual recipient number
$message = "Welcome to our service!";
echo sendSmsWithAuthToken($recipient, $message);
?>
{
    "sendezAddr": "PICEDC", 
    "cusTemplateId":"1607100000000340817", 
    "peId":"1101587860000063952", 
    "recipient": "919735907380", 
    "msg": "Dear kallol, Your OTP is 333. Thank you for joining with us. Pice Educare Pvt Ltd"
}