https://github.com/edison7500/django-leancloud-sms
Django LeanCloud SMS
https://github.com/edison7500/django-leancloud-sms
django leancloud python
Last synced: 3 months ago
JSON representation
Django LeanCloud SMS
- Host: GitHub
- URL: https://github.com/edison7500/django-leancloud-sms
- Owner: edison7500
- License: gpl-3.0
- Created: 2017-08-04T06:43:01.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-10T02:38:39.000Z (almost 8 years ago)
- Last Synced: 2025-02-06T05:15:52.110Z (3 months ago)
- Topics: django, leancloud, python
- Language: Python
- Homepage:
- Size: 43.9 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Django Leancloud SMS
[](https://travis-ci.org/edison7500/django-leancloud-sms)## 安装
```bash
pip install django-leancloud-sms# or
pip install requests # requests be must >= 2.1
git clone https://github.com/edison7500/django-leancloud-sms.git
cd django-leancloud-sms
python setup.py install
```## 使用方法
1. 在 django settings.py 设置以下配置
```pythonLEANCLOUD_HEADERS = {
"X-LC-Id": "",
"X-LC-Key": "",
"Content-Type": "application/json"
}LEANCLOUD_SMS_NAME = ""
```
2. 在 Django View 中使用
```python
'''
DJANGO Views.py
'''
from django.http import JsonResponse
from leancloud.sms import LeanCloudSMSdef send_sms_view(request):
phone_num = request.GET.get('num')
sms = LeanCloudSMS()
data, msg = sms.send_sms(phone_number=phone_num) # 发送验证码
return JsonResponse(status=200, data={
'status':data,
'msg':msg
})def verify_phone_code(request):
phone_num = request.GET.get('num')
v_code = request.GET.get('vcode')
sms = LeanCloudSMS()
data, msg = sms.verify_phone_code(phone_number=phone_num, verify_code=v_code) # 验证手机验证码
return JsonResponse(status=200, data={
'status':data,
'msg':msg
})
```