April 20, 2024
send sms using php

In this article, we will tell you How to send SMS (DLT SMS) using PHP from a website to a mobile phone in India. first, It should be clear, What is DLT (Distributed Ledger Technology)

How to send SMS (DLT SMS) using PHP:

What is DLT:  Distributed Ledger Technology (DLT) is a block-chain based registration system. It is implemented in the public interest to control SMS spam. whoever wants to send any type of  SMS to their customers needs to be DLT registered.

To send DLT SMS you need some API and Key credentials which will be provided by the SMS Service provider. To Send DTL SMS first you need to create a sender id, then you need to create an SMS template which will send to DLT authority to approve. once your SMS will be approved you will get templateId.

These are the main keys and credentials which you need to send  a DLT Approved SMS:
user:  provided by your SMS vendor
authkey: – provided by your SMS vendor
sender: – Approved Sender Id (ask your provider)
text: = Your DTL approved SMS text. (Only Approved SMS text will apply. either changing text or any phrase will cause SMS failure.)
entityid – Ask your Vendor
templateid – ask your vendor (Approved SMS text id)

Once you will all these things are ready we will start writing the code to send SMS in PHP:

//Remember: Only Apporved message text
$template_message = "YOUR MESSAGE TEXT HERE ";
$smshost = "https://your-sms-host.com/xyz";
$r = '';
$data = array
(
'user' => '_USER_ID',
'authkey' => 'AUTH_KEY',
"sender" => 'SENDER_ID',
'mobile' => MOBILE_NUMBER , // Recipient Mobile Number
'text' => $template_message,
'entityid' => 'ENTITY_ID',
'templateid' => 'TEMPLATE_ID',
);
$params = http_build_query($data);
$gateway = $smshost;
$apiUrl = $gateway."?".$params;
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$r = curl_exec($ch);
//If CURL module installed on server
if($r)
{
echo "Message Sent";
}
//If CURL module not installed on server
else
{
$data = file_get_contents($apiUrl);
$res = json_decode($data);
echo "Message Sent";
}

If still have some issues and you are looking for a professional and expert PHP developer. you can hire an Expert PHP Developer from acnosoft.com

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *