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

Considerations

Before you use the SDK sample code, pay attention to the following considerations:

  • You must use the default value of the RegionId parameter: ap-southeast-1.
  • You must use the default value of the endpoint parameter: https://dysmsapi.ap-southeast-1.aliyuncs.com.
  • You must use the default value of the apiVersion parameter: 2018-05-01.

Sample code

const Core = require('@alicloud/pop-core');
var client = new Core({
  accessKeyId: '<accessKeyId>',
  accessKeySecret: '<accessSecret>',
  endpoint: 'https://dysmsapi.ap-southeast-1.aliyuncs.com',
  apiVersion: '2018-05-01'
});
var params = {
  "RegionId": "ap-southeast-1",
  "To": "6212345678901",
  "From": "1234",
  "Message": "Have a test."
}
var requestOption = {
  method: 'POST'
};
client.request('SendMessageToGlobe', params, requestOption).then((result) => {
  console.log(result);
}, (ex) => {
  console.log(ex);
})