How to send SMS in PHP using own API

It is very easy to send SMS by using PHP language and now you can send SMS by using your own API. Here we will mention step by step procedure to send SMS in PHP using own API. MSG91 is one of the growing company in service provider field and they provide best API services to their customers. In their service, they provide a delivery report on notify URL.

In order to send messages by PHP, you have to enable the URL of PHP extension on your web server. You can also use the solution of AMP solution stack, these are the software stacks for a various operating system consisting MySQL database, Apache web server, and PHP programming language support. For sending SMS by PHP, first, you should enable the PHP curl extension for those whom you want to send SMS. In order to maintain the security SMS that you are sending, use HTTPS.

Designed your message and submit button that will send a request to a specified page in the action attribute of the form.

Before entering your text message, checked “toInput” field, you don’t have to check all the settings because POST HTTP method will automatically check everything. When you will load the page first time then none of these fields will be present. After checking all the fields, then define the URL for sending a request, and the structure of the request that is going to be sent.

Use this code to send SMS in PHP using own API

$postUrl = “”;

$destination = array(“messageId” => $messageId,

“to” => $to);

$message = array(“from” => $from,

“destinations” => array($destination),

“text” => $text,

“notifyUrl” => $notifyUrl,

“notifyContentType” => $notifyContentType,

“callbackData” => $callbackData);

$postData = array(“messages” => array($message));

$postDataJson = json_encode($postData)

This code is designed for sending SMS to one destination, for sending SMS to multiple destinations create another destination object. After creating an object add it to the destinations array.