How to send verification code in SMS using PHP?

If you want to send a verification code in SMS using PHP then, first of all, you have to learn basic PHP. Only then you can understand the process of sending a verification code in SMS. Now every retails websites and service based websites send a verification code to verify their customers. To send verification code mostly companies tie up with mobile operators to send bulk SMS. The charges of this operator are quite high so it is good to send verification SMS by using PHP language. MSG91 is one the best service provider company which provides API to send verification code for quickly.

To send a verification code in SMS using PHP language follow following steps:

1 First of all purchase the API code from MSG91.

2 Then add a number in which you want to send a verification code. You can also add multiple numbers by separating them with a comma.

3 Then route sender ID

4 Then add URL encoding and your text message

5 Use the code that is mentioned below to send a verification code in SMS using PHP successfully.

How to send verification code in SMS using PHP

How to send verification code in SMS using PHP

‘mobiles’ => $mobileNumber,
‘message’ => $message,
‘sender’ => $senderId,
‘route’ => $route
);

//API URL
$url=”https://control.msg91.com/api/sendhttp.php”;

// init the resource
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData
//,CURLOPT_FOLLOWLOCATION => true
));

//Ignore SSL certificate verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

//get response
$output = curl_exec($ch);

//Print error if any
if(curl_errno($ch))
{
echo ‘error:’ . curl_error($ch);
}
curl_close($ch);

echo $output;
?>