pip in stall ronglian_sms_sdk
def send_message(mobile, code, time):
'''
:param mobile: 手机号
:param code: 验证码
:param time: 分钟
:return:
'''
from ronglian_sms_sdk import SmsSDK
accId = 'xxxxxx'
accToken = 'xxxxxx'
appId = 'xxxxx'
sdk = SmsSDK(accId, accToken, appId)
tid = '1'
mobile = mobile
data = (code, time)
resp = sdk.sendMessage(tid, mobile, data)
print(resp)
if __name__ == '__main__':
send_message('手机号', '8888', '5')
pip install celery
from celery import Celery
import sys
sys.path.insert(0,'D:\demo\p8\opwf_project\celery_task')
celery_app = Celery(
'opwf',
broker='redis://127.0.0.1:6379/14',
backend='redis://127.0.0.1:6379/15',
@celery_app.task()
def send_message(tid,mobiles, datas):
'''
:param mobile: 手机号
:param code: 验证码
:param time: 分钟
:return:
'''
from ronglian_sms_sdk import SmsSDK
accId = 'xxx'
accToken = 'xxxx'
appId = 'xxxx'
sdk = SmsSDK(accId, accToken, appId)
resp = sdk.sendMessage(tid, mobiles, datas)
print(resp)
测试
from celery_task.main import send_message
send_message.delay('1','13939389145',('2344',2))
1、from celery_task.main import send_message
启动celery -A celery_task.main worker -l info
2、from main import send_message
启动celery -A main worker -l info