This topic describes how to use SMS SDK for Node.js to call the QueryMessage operation. This API operation allows you to query the statuses of text messages.
Request parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| MessageId | String | Yes | 1008***3003003 | The ID of the text message. |
Response parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
| ResponseCode | String | OK | The status that indicates whether the message sending request was submitted. |
| ResponseDescription | String | The SMS Send Request was accepted | The detailed description of the status that indicates whether the message sending request was submitted. |
| To | String | 6581177810 | The mobile phone number that received the text message. |
| Status | Number | 1 | The status that indicates whether the text message was sent.
|
| ErrorCode | String | DELIVERED | The status code that indicates whether the text message was sent. |
| ErrorDescription | String | success | The description of the status code that indicates whether the text message was sent. |
| Message | String | Hello! | The content of the text message. |
| SendDate | String | Mon, 24 Dec 2018 16:58:22 +0800 | The time when the text message was sent to the carrier. |
| ReceiveDate | String | Mon, 24 Dec 2018 16:58:22 +0800 | The time when the delivery receipt was received from the carrier. |
| NumberDetail | String | The details of the mobile phone number. | |
| └Country | String | Hongkong, China | The country to which the mobile phone number belongs. |
| └Region | String | HongKong | The region to which the mobile phone number belongs. |
| └Carrier | String | CMI | The carrier that provides the mobile phone number. |
Install the core library of Alibaba Cloud SDK for Node.js
- Method 1: Use the npm and Yarn package managers.
npm install @alicloud/pop-core - Method 2: Click Alibaba Cloud SDK for Node.js to download the core library of Alibaba Cloud SDK for Node.js.
Sample requests
- You must set the regionId parameter to ap-southeast-1.
- You must set the endpoint parameter to https://dysmsapi.ap-southeast-1.aliyuncs.com.
- You must set the version parameter to 2018-05-01.
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",
"MessageId": "140101545641902498"
}
var requestOption = {
method: 'POST'
};
client.request('QueryMessage', params, requestOption).then((result) => {
console.log(result);
}, (ex) => {
console.log(ex);
})