sms.py 优化
This commit is contained in:
parent
029459ce5e
commit
34de8fdfec
|
@ -1,3 +1,4 @@
|
||||||
SIGN_MAKE_FAIL = {"code": "sign_make_fail", "detail": "签名照生成失败,请重新上传"}
|
SIGN_MAKE_FAIL = {"code": "sign_make_fail", "detail": "签名照生成失败,请重新上传"}
|
||||||
PKS_ERROR = {"code": "pks_error", "detail": "未获取到主键列表"}
|
PKS_ERROR = {"code": "pks_error", "detail": "未获取到主键列表"}
|
||||||
WX_REQUEST_ERROR = {"code": "wx_request_error", "detail": "微信接口访问异常"}
|
WX_REQUEST_ERROR = {"code": "wx_request_error", "detail": "微信接口访问异常"}
|
||||||
|
XX_REQUEST_ERROR = {"code": "xx_request_error", "detail": "寻息接口访问异常"}
|
|
@ -3,13 +3,14 @@ from aliyunsdkcore.request import CommonRequest
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from apps.utils.myconfig import myConfig
|
||||||
|
|
||||||
# 实例化myLogger
|
# 实例化myLogger
|
||||||
myLogger = logging.getLogger('log')
|
myLogger = logging.getLogger('log')
|
||||||
|
|
||||||
|
|
||||||
def send_sms(phone: str, template_code: int, template_param: dict):
|
def send_sms(phone: str, template_code: int, template_param: dict):
|
||||||
client = AcsClient(settings.XNIU_SMS_KEY, settings.XNIU_SMS_SECRET, 'default')
|
client = AcsClient(myConfig.get_option_value('sms', 'xn_key'), myConfig.get_option_value('sms', 'xn_secret'), 'default')
|
||||||
request = CommonRequest()
|
request = CommonRequest()
|
||||||
# 固定json
|
# 固定json
|
||||||
request.set_accept_format('json')
|
request.set_accept_format('json')
|
||||||
|
@ -26,7 +27,7 @@ def send_sms(phone: str, template_code: int, template_param: dict):
|
||||||
# 手机号码
|
# 手机号码
|
||||||
request.add_query_param('PhoneNumbers', phone)
|
request.add_query_param('PhoneNumbers', phone)
|
||||||
# 签名名称
|
# 签名名称
|
||||||
request.add_query_param('SignName', "曲阳金隅EHS")
|
request.add_query_param('SignName', settings.PROJECT_NAME)
|
||||||
# 模板CODE
|
# 模板CODE
|
||||||
request.add_query_param('TemplateCode', template_code)
|
request.add_query_param('TemplateCode', template_code)
|
||||||
# 如果有模板参数 填写模板参数 如果无 无须填写
|
# 如果有模板参数 填写模板参数 如果无 无须填写
|
||||||
|
|
Loading…
Reference in New Issue