Send OTP using textlocal api in laravel
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('https://api.textlocal.in/send/?' . $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($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
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
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.
Random Code Snippet Queries: Laravel
- Display option of select as selected with blade directive Laravel
- How to create and run user seeder in laravel
- Count all and get 10 records after where condition in laravel
- Get all users except the followings users in overtrue laravel-follow
- Laravel 11 project setup on localhost using breeze with blade step by step
- Cast Array to an Object in Controller and then pass to view in laravel
- Method Illuminate\Database\Eloquent\Collection::lists does not exist
- How to call Laravel route in jQuery
- Use of undefined constant laravel
- Laravel upload file with original file name
- How to add background image to div using Tailwindcss, Vite in Laravel Environment
- Define variable and use in Laravel controller method
- How to upload local Laravel project to server ?
- Composer create project laravel/laravel example app
- How to add columns in existing table using migration in laravel
- Show old value while editing the form in Laravel
- How to display a specific word from a string in laravel
- Laravel specific table Migration
- Insert dummy data in users table Laravel
- Laravel create default admin user
- How to pass link from controller to view in laravel on ajax call
- How to get user information using hootlex/laravel-friendships package in laravel
- Laravel get all records with pagination
- How to add unique records in pivot columns of Laravel pivot table
- Composer\Exception\NoSslException