Send OTP using textlocal api in laravel

Created at 21-Sep-2021 , By samar

Send OTP using textlocal api in laravel

In this session, we are going to try to solve the "Send OTP using textlocal api in laravel" puzzle by using the computer language.

Sometimes you have to send the OTP for mobile verification. You can send the OTP using textlocal API in laravel.
  • Sample code snippet to send otp using textlocal with get method in laravel

    Route::get('/send-otp', function(){
        $apiKey = urlencode('Your_api_key');
        // Message details
        $numbers = urlencode('91xxxxxxxxxx'); //Mobile number on which you want to send message
        $sender = urlencode('SENDER_NAME'); 
        $message = rawurlencode('123456 is OTP for platform verification. Valid for 30 Minutes. Do not Share it with anyone. Contact Us if not initiated by you.');
        // Prepare data for POST request
        $data = 'apikey=' . $apiKey . '&numbers=' . $numbers . "&sender=" . $sender . "&message=" . $message;
        // Send the GET request with cURL
        $ch = curl_init('' . $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        // Process your response here
        echo $response;

    This is the sample code snippet for sending OTP using text local api using GET method in laravel. It’s working in my case. If you find any error please check the message it should be the same as per the DLT template message and text local template, number should have prefix with country code 91. 


    In case of error please visit - Solution for invalid template error code 80 in textlocal sms API

Back to code snippet queries related laravel

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.