This topic provides a comprehensive guide on how to utilize Alibaba Cloud SMS SDK for Python. By incorporating this SDK as a dependency in your application, you can easily integrate the SendMessageToGlobe operation, enabling you to send SMS messages to various regions around the world, excluding the Chinese mainland.
Usage notes
When you construct the AcsClient object, you must use the default value of the regionId parameter. The default value is ap-southeast-1. Note that regionId is the third parameter when you construct the AcsClient object.
You must use the default domain name: dysmsapi.ap-southeast-1.aliyuncs.com.
You must use the default API version number: 2018-05-01.
Sample code
#!/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('SendMessageToGlobe')
request.add_query_param('To', '62813****7451')
request.add_query_param('From', '1234')
request.add_query_param('Message', 'Have a test.')
response = client.do_action(request)
# python2: print(response)
print(str(response, encoding = 'utf-8'))