签名管理
更新时间:2021-06-08
申请签名
通过以下代码可以申请一个SMS签名:
try:
fin = open('/path/xxx.png', 'rb')
pic_str = base64.b64encode(fin.read())
fin.close()
response = sms_client.create_signature(content="百度", content_type="Enterprise",
signature_file_base_64=pic_str,
signature_file_format="png")
except ex.BceHttpClientError as e:
if isinstance(e.last_error, ex.BceServerError):
LOG.error('send request failed. Response %s, code: %s, request_id: %s'
% (e.last_error.status_code, e.last_error.code, e.last_error.request_id))
else:
LOG.error('send request failed. Unknown exception: %s' % e)
提示: 详细的参数配置及限制条件,可以参考SMS API详情申请签名
获取签名详情
通过以下代码,可以获取一个SMS签名详情:
try:
response = sms_client.get_signature_detail(signature_id)
except ex.BceHttpClientError as e:
if isinstance(e.last_error, ex.BceServerError):
LOG.error('send request failed. Response %s, code: %s, request_id: %s'
% (e.last_error.status_code, e.last_error.code, e.last_error.request_id))
else:
LOG.error('send request failed. Unknown exception: %s' % e)
提示: 详细的参数配置及限制条件,可以参考SMS API详情查询签名
变更签名
通过以下代码,可以更新指定的签名:
try:
response = sms_client.update_signature(content="BaiduSms", content_type="MobileApp", country_type="GLOBAL",
signature_id=signature_id)
except ex.BceHttpClientError as e:
if isinstance(e.last_error, ex.BceServerError):
LOG.error('send request failed. Response %s, code: %s, request_id: %s'
% (e.last_error.status_code, e.last_error.code, e.last_error.request_id))
else:
LOG.error('send request failed. Unknown exception: %s' % e)
提示: 详细的参数配置及限制条件,可以参考SMS API详情变更签名
删除签名
通过以下代码,可以删除指定的签名:
try:
response = sms_client.delete_signature(signature_id)
except ex.BceHttpClientError as e:
if isinstance(e.last_error, ex.BceServerError):
LOG.error('send request failed. Response %s, code: %s, request_id: %s'
% (e.last_error.status_code, e.last_error.code, e.last_error.request_id))
else:
LOG.error('send request failed. Unknown exception: %s' % e)
提示: 详细的参数配置及限制条件,可以参考SMS API详情删除签名