本文为您介绍了Python调用QueryMessage查看短信状态。
请求参数
名称 |
类型 |
是否必选 |
示例值 |
描述 |
MessageId |
String |
是 |
10080***003003 |
短信发送ID。 |
返回参数
名称 |
类型 |
示例值 |
描述 |
ResponseCode |
String |
OK |
短信提交的状态。 |
ResponseDescription |
String |
The SMS Send Request was accepted |
短信提交状态的详细描述。 |
To |
String |
6581177810 |
发送号码。 |
Status |
Number |
1 |
短信的发送状态:
- 1(Submitted)
- 2(Failed)
- 3(Delivered)
|
ErrorCode |
String |
DELIVERED |
短信的发送状态码。 |
ErrorDescription |
String |
success |
短信发送状态码的详细描述。 |
Message |
String |
Hello! |
短信内容。 |
SendDate |
String |
Mon, 24 Dec 2018 16:58:22 +0800 |
短信转发给运营商的时间。 |
ReceiveDate |
String |
Mon, 24 Dec 2018 16:58:22 +0800 |
短信收到运营商回执的时间。 |
NumberDetail |
String |
号码的详细属性。 |
└Country |
String |
Hongkong, China |
号码所属国家。 |
└Region |
String |
HongKong |
Number Region。 |
└Carrier |
String |
CMI |
号码所属的运营商网络。 |
调用示例
- 构造AcsClient时,第三个参数(regionId)必须为ap-southeast-1,请勿修改。
- domain必须为dysmsapi.ap-southeast-1.aliyuncs.com,请勿修改。
- version必须为2018-05-01,请勿修改。
#!/usr/bin/env python
#coding=utf-8
import os
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
client = AcsClient('<accessKeyId>', '<accessSecret>', 'ap-southeast-1')
request = CommonRequest()
request.set_accept_format('json')
request.set_domain('dysmsapi.ap-southeast-1.aliyuncs.com')
request.set_method('POST')
request.set_version('2018-05-01')
request.set_action_name('QueryMessage')
request.add_query_param('MessageId', '140101545641902498')
response = client.do_action(request)
# python2: print(response)
print(str(response, encoding = 'utf-8'))