sms.py 优化

This commit is contained in:
caoqianming 2023-03-02 16:58:38 +08:00
parent 029459ce5e
commit 34de8fdfec
2 changed files with 4 additions and 2 deletions

View File

@ -1,3 +1,4 @@
SIGN_MAKE_FAIL = {"code": "sign_make_fail", "detail": "签名照生成失败,请重新上传"}
PKS_ERROR = {"code": "pks_error", "detail": "未获取到主键列表"}
WX_REQUEST_ERROR = {"code": "wx_request_error", "detail": "微信接口访问异常"}
XX_REQUEST_ERROR = {"code": "xx_request_error", "detail": "寻息接口访问异常"}

View File

@ -3,13 +3,14 @@ from aliyunsdkcore.request import CommonRequest
from django.conf import settings
import json
import logging
from apps.utils.myconfig import myConfig
# 实例化myLogger
myLogger = logging.getLogger('log')
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()
# 固定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('SignName', "曲阳金隅EHS")
request.add_query_param('SignName', settings.PROJECT_NAME)
# 模板CODE
request.add_query_param('TemplateCode', template_code)
# 如果有模板参数 填写模板参数 如果无 无须填写