In this tutorial I am going to discuss how to send SMS using Nexmo.
First you have to sign up in Nexmo website and you can use your free account for testing
Then you can install the PHP client library using Composer
composer require nexmo/laravel
You can add Nexmo\Laravel\NexmoServiceProvider
to the providers array in your config/app.php
'providers' => [ // other code Nexmo\Laravel\NexmoServiceProvider::class, ],
In your .env file. You can put the key and secret
NEXMO_KEY=c2f2ecaa NEXMO_SECRET=23324de3c4b9a7b6
Now you can create route in routes\web.php file
Route::get('/sms', 'SMSController@send');
In your SMSController, you can put the following code to send SMS
public function send(){ Nexmo::message()->send([ 'to' => '000773524056', 'from' => '16105552344', 'text' => 'Using the facade to send a message.' ]); }
Now you can send the SMS using following URL http://127.0.0.1:8001/sms
You can see the SMS like this in your phone