All Products
Search
Document Center

:Node.js SDK

Last Updated:Apr 13, 2023

This topic provides a comprehensive guide on how to utilize Alibaba Cloud SMS SDK for Node.js. 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

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

  • 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);
})