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
- Connection could not be established with host smtp.gmail.com :stream_socket_client(): unable to connect to tcp://smtp.gmail.com:587 (Connection refused)"
- Post table seeder laravel 10
- How to add foreign key in laravel using migration
- Laravel insert query not working
- How to print form data in laravel
- Use of undefined constant laravel
- How to insert multiple rows in mysql using loop in laravel?
- Laravel onclick function not working
- Root composer.json requires php ^7.3 but your php version (8.0.0) does not satisfy that requirement
- How to use or operator in laravel
- Display message with session flash using bootstrap alert class in laravel
- Always load the relationship data with eager loading in Laravel
- Print query in laravel
- How to decrypt laravel password
- Route [password.request] not defined
- Automatically remove records using Prunable trait in Laravel
- How to check query string exists or not in laravel blade
- How to display user profile after login in laravel
- How to pass variable from controller to model in Laravel
- How to get images from AWS s3 and display in Laravel blade
- How to validate URL with https using regex in laravel
- How to send ID to another page in Laravel
- Create records using relationship in laravel
- Validation for multiple forms on same page in laravel
- Laravel pagination links with query string