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
- Laravel create default admin user
- Argument 1 passed to Symfony\Component\HttpFoundation\Response::setContent() must be of the type string or null, object given
- How to get all posts which contains comments in laravel
- How to send email in laravel
- Class 'Facade\Ignition\IgnitionServiceProvider' not found
- Skip first n record and display rest records in laravel view
- Laravel 11 sanctum api authentication example code
- Laravel hasmany select not working
- Retain selected value of select box in Laravel
- How to add class to tr in table using foreach in laravel
- Array to string conversion laravel blade
- In order to use the Auth::routes() method, please install the laravel/ui package
- How to upload files to amazon s3 bucket using Laravel
- Convert multidimensional array to single array in Laravel
- How to change default timestamp fields name in Laravel
- Composer\Exception\NoSslException
- Redirect from www to non www in laravel using htaccess
- Php artisan make model, factory, migration and controller in single command
- Ignore Records where a field has NULL value in Laravel
- How to fetch single row data from database in laravel
- How to add unique records in pivot columns of Laravel pivot table
- How to create and run user seeder in laravel
- SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist
- Laravel get all records with pagination
- How to pass data to multiple partial view files in laravel