Python 3 Script to Send SMS and Verify OTP to Mobile Number Using msg91-sms Package Full Project For Beginners

 

Welcome folks today in this blog post we will be sending sms and verify otp to mobile number using msg91-sms in python. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to install the below package using the pip command as shown below

 

 

pip install msg91-sms

 

See also  Python 3 Datetime Module Script to Compare and Sort Two Dates Full Example For Beginners

 

After installing this library you need to make an app.py file and copy paste the following code

 

 

app.py

 

 

import msg91_sms as msgsms

msg = msgsms.Cspd_msg91(apikey='YOUR MSG91 API KEY')
sms_txt = "This is a text SMS from MSG91"
send_sms_resp = msg.send(4,'TXTIN','919999999999',sms_txt)
print(send_sms_resp)

 

 

 

And also you can send otp and verify it as shown below

 

 

otp_sms_txt = "Your otp code is ##OTP##"
send_otp_sms_resp = msg.send_otp('TXTIN',919999999999,otp_sms_txt)
print(send_otp_sms_resp)

 

See also  Python 3 PyGame Billiards Cue Snooker Pool Game GUI Desktop App Full Project For Beginners

 

 

verify otp

 

 

otp_verify_response = msg.verify_otp(919999999999,OTP_code)
print(otp_verify_response)

 

 

resend otp

 

 

resend_otp_sms_resp = msg.resend_otp(919999999999)
print(resend_otp_sms_resp)

 

Leave a Reply