Laravel 9 - How to send SMS using Twilio in Laravel ( english )

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys and welcome to laravel 9 tutorials so guys in this specific video we are going to see how can we integrate SMS service in laravel as you can see I have created a notepad file right here on the desktop with the name laravel tro SMS service so simply guys we can use tro service to implement SMS uh or let's say to integrate SMS in larel it's quite simple and easy and the steps are uh like straightforward okay we are going to see this in this specific video so yeah guys where can we use this SMS functionality let's say uh in your application whenever a user is trying to log in you need to send an SMS uh let's say for the verification code you can use SMS uh let's say lar Tru let's say let's take another scenario let's say you have some confidential settings on your application and let's say whenever someone is trying to change those setting you need to verify that the user is valid once again you can use SMS service by sending the verification code and verifying the code on the application side so yeah guys uh that's it so let's start without further talking so first of all I'm going to open this notepad file right here okay and let's start with the step one which is quite basic in this case we need to create a Le uh fresh laravel project so let me access G batch right here okay so I first of all I'm going to access HD HD do folder CDC Zam HD dos just like that okay so guys you can simply create a fresh LEL project using this command okay in my case I have laravel globally installed so I can simply use laravel new SMS this is the project name okay this one right here so if you have larel globally installed you can simply use this command if not you need to use this one in my case I'm assigning the SMS uh the project name different from here because I have already uh created a project with the name SMS for the Udu and Hindi lecture so in this case I'm going to use SMS one so yeah guys uh that's it and let's say uh in your case you want to uh Implement 2o SMS integration into an existing application in that case you don't need to create a fresh laravel project so you need to skip this step but it's always better to test the functionality first before implementing it into the real life scenario so that's why I'm going to create a fresh larel project but just wanted to let you know yeah so guys uh this is going to take some time and to save the time I'm going to pause the video and once it's done I'm going to resume okay guys so it's done we have a fresh larav project now so now we can proceed to step number two which is creating a tro account so you can simply use this link and you don't need to copy or pause the video to see everything written right here I'm going to uh let's say create a link for you for of this file specific file and I will share it maybe using Google drive or else I'm going to paste the whole whole code in the description so you can simply copy and paste okay so yeah guys let's move to Google I'm going to paste the link just like right here and in my case I have already created an account so in your case what you need to do is first sign up and then it will ask you for your number to verify uh that it's a valid number and it's an important step so you need to verify your phone number as well okay after that you can once the account is created and you have defined your number what you can do is guys you will move to console by clicking on the console link okay and you will land on the same page right here and here you are going to see a popup okay and it is going to ask you let's say if you want a 12 number you need to confirm or you need to click somewhere right here okay and after clicking that specific link you are going to have this field enable before that you won't see this field right here okay so in in the first place you are going to see account as ID account token that's it and you will see a popup right here and in your case if you want a 12o number to test this functionality you need to confirm it okay after that it is going to assign you a unique 12o number just like right here okay so yeah guys now we are going to use these three fields and everything is written right here on the notepad file so I'm just going to copy these three lines right here and let's access the subline so let's access our project because I'm in the blog right now now so open folder HD docs and I'm looking for the SMS one this one right here okay and yeah let's close this one the old one right here let's move and now let's navigate Tov file let's move down I'm going to paste everything right here just like that now we can simply copy the codes from here okay so first I need account SI let's move to Sublime and let's paste it right here just like that let's move once again this time let's copy the token replace with this one the token one and let's copy the phone number tell your phone number it's not mine okay yeah guys okay so that's it now let's move to notepad now the step three is to install the 12o SDK for that once again we will move to G bash first let me copy this composer Command right here okay copy let's move to G bash right here and let's paste it just like that once again it is going to take some time so I'm going to pause the video once it's done I will resume okay sorry for the mistake guys uh first what we need to do is we need to access the project folder sorry for that guys okay so let's move and let's access our for project folders in my case it is SMS 1 in your case it would be something like SMS or whatever the name you have assigned so yeah let's access this and now once again I need to run this command okay sorry for that guys and once again it is going to take some time so I'm going to pause okay guys so now you can see it's done now we can proceed to step number four which is creating a route so I have the complete Command right here and let me copy this one copy let's move to Sublime right here let's move to web.php okay let's paste it right here okay we are going to use this rout uh route to test the SMS functionality so just that uh keep that in mind okay yeah let's move to step number five which is creating a controller so I can simply copy this command once again okay that's why I've created this notepad file okay guys yeah so let's move to get bash and let's paste the code simple command guys you can do that okay okay so yeah let's move forward and now we will move to step number six which is copying the below code written right here so I'm going to copy this whole code to save the time till here PHP and let's move to tro controller tro SMS controller actually so CR a and replace everything just like that so let's discuss something right here so receiver number here you are going to put the number of the receiver in my case let's say it would be uh because I'm located in Saudi Arabia so I can write 966 and I'm going to type a random number first of all just like that okay so that we can see the error okay the message is all about larell then we are uh implementing try and catch so we are getting the account S ID from the EnV file that we implemented right here you can see the Sid okay similarly we are getting the token from the EnV file and once again we are getting the 12u number from the EnV then we are creating a request client request where we are passing account Sid and the token and we are creating a message with the receiver number uh to the form uh let's say we are going to send the SMS using this number and the message would be which is written right here so as simple as that once it uh once it is done we can simply uh see a SMS sent successful message using DD otherwise we are going to see the error just like that okay so now we can test this and uh in order to test this functionality we need to run the project guys okay so PHP artian so let's move to Google um sorry this one and let's move to 127.0.0.1 just like that now we can simply hit the route send SMS so in this case we are going to receive an error unable to create record the two number this is not a valid phone number so you can see right here it's totally a random number guys okay so now I'm going to put my number right here so that's why I'm going to maybe blur it okay okay guys so okay now this is a valid number now let's test the link once again so hit let's hit route so send SMS okay guys so SMS sent successfully now where can we see this SMS so let's move to console trilo console so let's move to from develop to monitor let's move to Monitor and let's access the logs let's access the message and right here you will see the latest message okay um so right here this is the latest message you can see the time okay so it's in UTC right here this is the latest message and right here let me show the detail if you are going to click on this link you will see the all the details actually so yeah let it load message detail you can see the ID message service Etc and the body right here so in order to use TWU you need to upgrade to the TWU account you need to upgrade your tro account to use it so yeah guys it's uh like you need to pay something okay so yeah but if the implementation is easy you can see how simple it is you can send the an SMS just like that on the go so yeah guys that's it from this specific video I hope you guys like this video if you liked it please like subscribe and share thank you take care and yes guys be ready for the next one okay take care
Info
Channel: All About Laravel
Views: 5,830
Rating: undefined out of 5
Keywords: laravel 9 sms, laravel 9 sms twilio, laravel sms notification, laravel sms verification, laravel sms gateway, laravel sms api free, laravel twilio sms, laravel mobile number sms verification, laravel sms notification tutorial, laravel sms api, laravel send sms free, laravel send sms, laravel send sms using twilio, laravel, laravel 9, laravel 9 tutorials, laravel 9 tutorial in english, laravel for beginners 2022, laravel tuts, laravel 9 tuts, twilio, how to send sms in laravel
Id: ZIxEgEk141U
Channel Id: undefined
Length: 10min 49sec (649 seconds)
Published: Wed Apr 27 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.