All Products
Search
Document Center

Python

Last Updated: Nov 26, 2019

Input parameters

Name Type O/M Example Description
MessageId String Mandatory 10080303003003 The ID generated by Alibaba Cloud to uniquely identify the serial number of SMS sending request.

Output parameters

Name Type Example Description
ResponseCode String OK The returned status code that indicates whether the call is successful. A value of OK indicates that the call is successful. Other values indicate that the call has failed. For more information, see Status codes.
ResponseDescription String The SMS Send Request was accepted The description of the returned status code.
To String 6581177810 The phone number of the SMS message recipient.
Status Number 1 The status of the SMS message. Valid values: 1 (Success), 0 (Fail).
ErrorCode String DELIVERED The returned error code.
ErrorDescription String success The returned error message.
Message String Hello! The content of the SMS message.
SendDate String Mon, 24 Dec 2018 16:58:22 +0800 The time and date when the SMS message was sent.
ReceiveDate String Mon, 24 Dec 2018 16:58:22 +0800 The time and date when the SMS message was received.
NumberDetail String Detailed information of the number
└Country String Hongkong, China Number Country
└Region String HongKong Number Region
└Carrier String CMI Number Carrier/Network

Developer integration process

1.Core-sdk import

Option 1,Install with Pip

  1. pip install aliyun-python-sdk-core

Option 2,Core-sdk download: Python API SDK

2.Writing a sample program

When calling the interface, please note:

  • When creating “AcsClient”, the third parameter (regionId) must be “ap-southeast-1”, please do not modify it.
  • domain must be “sms-intl.ap-southeast-1.aliyuncs.com”, please do not modify it.

  • version must be 2018-05-01, please do not modify it.

  1. #!/usr/bin/env python
  2. #coding=utf-8
  3. import os
  4. from aliyunsdkcore.client import AcsClient
  5. from aliyunsdkcore.request import CommonRequest
  6. client = AcsClient('<accessKeyId>', '<accessSecret>', 'ap-southeast-1')
  7. request = CommonRequest()
  8. request.set_accept_format('json')
  9. request.set_domain('sms-intl.ap-southeast-1.aliyuncs.com')
  10. request.set_method('POST')
  11. request.set_version('2018-05-01')
  12. request.set_action_name('QueryMessage')
  13. request.add_query_param('MessageId', '140101545641902498')
  14. response = client.do_action(request)
  15. # python2: print(response)
  16. print(str(response, encoding = 'utf-8'))