This topic describes how to use SMS SDK for Python to call the QueryMessage operation. This API operation allows you to query the statuses of text messages.

Request parameters

Parameter Type Required Example Description
MessageId String Yes 10080***003003 The ID of the text message.

Response parameters

Parameter Type Example Description
ResponseCode String OK The status that indicates whether the message sending request was submitted.
ResponseDescription String The SMS Send Request was accepted The detailed description of the status that indicates whether the message sending request was submitted.
To String 6581177810 The mobile phone number that received the text message.
Status Number 1 The status that indicates whether the text message was sent.
  • 1 (Submitted)
  • 2 (Failed)
  • 3 (Delivered)
ErrorCode String DELIVERED The status code that indicates whether the text message was sent.
ErrorDescription String success The description of the status code that indicates whether the text message was sent.
Message String Hello! The content of the text message.
SendDate String Mon, 24 Dec 2018 16:58:22 +0800 The time when the text message was sent to the carrier.
ReceiveDate String Mon, 24 Dec 2018 16:58:22 +0800 The time when the delivery receipt was received from the carrier.
NumberDetail String The details of the mobile phone number.
Country String Hongkong, China The country to which the mobile phone number belongs.
Region String HongKong The region to which the mobile phone number belongs.
Carrier String CMI The carrier that provides the mobile phone number.

Install the core library of Alibaba Cloud SDK for Python

  • Method 1: Use the pip package installer.
    pip install aliyun-python-sdk-core
                        
  • Method 2: Click Alibaba Cloud SDK for Python to download the core library of Alibaba Cloud SDK for Python.

Sample requests

  • When you construct the AcsClient object, the value of the regionId parameter must be ap-southeast-1 and cannot be modified.
  • You must set the domain parameter to dysmsapi.ap-southeast-1.aliyuncs.com.
  • You must set the version parameter to 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'))