当前位置:网站首页>The process and specific code of sending SMS verification code using flask framework
The process and specific code of sending SMS verification code using flask framework
2022-07-31 05:34:00 【The flowers are blooming in the south of the city^】
1. Flow chart of obtaining SMS verification code

2. Ronglian Cloud Configuration
Register an account on Ronglian Cloud's official website and use three IDs to send SMS verification codes
ACCOUNT SID (Master Account ID)
AUTH TOKEN (Account Authorization Token)
AppID (AppID)

3. Add test phone number (required)

4. Install Ronglian Cloud SDK on the flask backend
pip install ronglian_sms_sdk
Send SMS to call configuration
import jsonfrom ronglian_sms_sdk import SmsSDK def send_message(sms_code,mobile,expire=5):sms_sdk = SmsSDK(accId='8aaf03013************************',appId='8aaf07087f77bf96017fddbf5f3e3334',accToken='b2033c3b6d3b4dd6b931a138a8246af1')tid = '1'datas = ("%s"%sms_code,"%s"%expire) res = sms_sdk.sendMessage(tid=tid,mobile=mobile,datas=datas)resd=json.loads(res)return resd
Send verification code view
Here is to use the mobile phone number as the key when saving into redis
import redisfrom flask import jsonifyfrom flask_restful import Resource,reqparse # Generate and store SMS verification code class Scode(Resource):def get(self):paser = reqparse.RequestParser()Paser.add_argument('mobile') args = paser.parse_args()mobile = args.get('mobile') sms_code = random.randint(100000,999999)send_message(sms_code,mobile) # Store the verification code in redisr = redis.Redis(host='localhost',db=0,port=6379)sms_key = "sms_code:%s"%mobiler.set(sms_key,sms_code,ex=300) print("<<>>",sms_code) Return jsonify(msg = "The verification code has been sent, please pay attention to check",code=200)
Trigger the function to get the verification code and send it successfully
———————————————
边栏推荐
- 关于LocalDateTime的全局返回时间带“T“的时间格式处理
- [Introduction to MySQL 8 to Mastery] Basics - silent installation of MySQL on Linux system, cross-version upgrade
- Temporal对比Cadence
- 【mysql 提高查询效率】Mysql 数据库查询好慢问题解决
- MySQL8.0.26安装配置教程(windows 64位)
- 剑指offer专项突击版 ---- 第 6 天
- CentOS7 - yum install mysql
- pytorch中的一维、二维、三维卷积操作
- Redis 事务学习有感
- Tapdata 与 Apache Doris 完成兼容性互认证,共建新一代数据架构
猜你喜欢

有了MVC,为什么还要DDD?
![【JS面试题】面试官:“[1,2,3].map(parseInt)“ 输出结果是什么?答上来就算你通过面试](/img/7a/c70077c7a95137aaeb49c344c82696.png)
【JS面试题】面试官:“[1,2,3].map(parseInt)“ 输出结果是什么?答上来就算你通过面试

第7章 网络层第3次练习题答案(第三版)

Distributed transaction processing solution big PK!
uni-app进阶之内嵌应用【day14】
【一起学Rust】Rust学习前准备——注释和格式化输出
![[Introduction to MySQL 8 to Mastery] Basics - silent installation of MySQL on Linux system, cross-version upgrade](/img/af/7a2cdcc6535c04c508c9ddf9ee0cb2.png)
[Introduction to MySQL 8 to Mastery] Basics - silent installation of MySQL on Linux system, cross-version upgrade

Anaconda configure environment directives

实验8 DNS解析

运用flask框架发送短信验证码的流程及具体代码
随机推荐
【C语言趣味小游戏——猜数字】
有了MVC,为什么还要DDD?
质量小议12 -- 以测代评
Input length must be multiple of 8 when decrypting with padded cipher
Proteus 8 Professional安装教程
The interviewer asked me TCP three handshake and four wave, I really
剑指offer基础版 ----- 第25天
关于superset集成到自己的项目中
“档次法”——用于物品体积分布不均匀的01背包问题的求解方法
【LeetCode-SQL每日一练】——2. 第二高的薪水
Linux系统安装mysql(rpm方式安装)
数据库上机实验3 连接查询和分组查询
数据库上机实验4 数据更新和视图
Flask 的初识
Apache DButils使用注意事项--with modifiers “public“
Sword Point Offer Special Assault Edition ---- Day 1
【C语言3个基本结构详解——顺序、选择、循环】
C语言指针详解
Minio upload file ssl certificate is not trusted
数据库上机实验5 数据库安全性