This topic provides a demo to describe how to use the Alibaba Cloud SDK for Python to call the SendMessageToGlobe operation. This API operation allows you to send text messages to the regions outside Mainland China.

Considerations

  • 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'))