This article introduces Short Message Service SMS receipt API and Node.js parameter description.
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
MessageType | String | Yes | SmsReport | There is a message type: SmsReport. |
QueueName | String | Yes | Alicom-Queue-xxxxxx-SmsReport | The name of the message queue provided by Alibaba can be viewed in the SMS console-system settings. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
MessageId | String | 100803***03003 | The sending ID of the text message. |
To | String | 45***0121 | The sending number of the text message. |
Status | Number | 3 | The status that indicates whether the text message was sent. 1 (Submitted), 2 (Failed), and 3 (Delivered). |
ErrorCode | String | success | The error code returned by SMS sending. |
ErrorDescription | String | success | A detailed description of the error codes returned by SMS sending. |
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
Download the SDK. Click to view the download link cluster.
Sample requests
/** * The is a DEMO that introduces how to use SMS send Api/SMS query Api/ SMS Delivery Report API. * Created on 2018-06-20 */ const SMSClient = require('@alicloud/international-sms-sdk') // AccessKey and AccessKeySecret , you can login sms console and find it in API Management const accessKeyId = 'yourAccessKeyId' const secretAccessKey = 'yourAccessKeySecret' // Message Quenue Name, you can get it from SMS console, like:Alicom-Queue-xxxxxx- const queueName = 'Alicom-Queue-xxxxxxxxxxxx-' // initiate SMSClient let smsClient = new SMSClient({accessKeyId, secretAccessKey}) // SMS Delivery Report smsClient.receiveMsg(0, queueName).then(function (res) { let {code, body}=res if (code === 200) { //parse messagebody and please start your own code here console.log(body) } }, function (err) { // The exception caused by your own code. Message will not be deleted and be pushed again console.log(err) })