All Products
Search
Document Center

Node.js

Last Updated: Mar 19, 2019

Input parameters

Name Type O/M Example Description
MessageType String Mandatory SmsReport SmsReport
QueueName String Mandatory Alicom-Queue-xxxxxx-SmsReport The name of the message queue returned from the console——System Setting.

Output parameters

Name Name Example Description
MessageId String 10080303003003 The ID generated by Alibaba Cloud to uniquely identify an SMS message.
To String 452220121 The phone number of the SMS message recipient.
Status Number 3 The status of the SMS message. Valid values: 1 (Delivered), 2 (Failed), and 3 (Submitted).
ErrorCode String success The returned error code.
ErrorDescription String success The returned error message.
SendDate String Mon, 24 Dec 2018 16:58:22 +0800 The time and date when the SMS message was sent.
ReceiveDate String Mon, 24 Dec 2018 16:58:22 +0800 The time and date when the SMS message was received.

Developer integration process

1.SDK download: Click to view the download link

2.Writing a sample program

  1. /**
  2. * The is a DEMO that introduces how to use SMS send Api/SMS query Api/ SMS Delivery Report API.
  3. * Created on 2018-06-20
  4. */
  5. const SMSClient = require('@alicloud/international-sms-sdk')
  6. // AccessKey and AccessKeySecret , you can login sms console and find it in API Management
  7. const accessKeyId = 'yourAccessKeyId'
  8. const secretAccessKey = 'yourAccessKeySecret'
  9. // Message Quenue Name, you can get it from SMS console, like:Alicom-Queue-xxxxxx-
  10. const queueName = 'Alicom-Queue-xxxxxxxxxxxx-'
  11. // initiate SMSClient
  12. let smsClient = new SMSClient({accessKeyId, secretAccessKey})
  13. // SMS Delivery Report
  14. smsClient.receiveMsg(0, queueName).then(function (res) {
  15. let {code, body}=res
  16. if (code === 200) {
  17. //parse messagebody and please start your own code here
  18. console.log(body)
  19. }
  20. }, function (err) {
  21. // The exception caused by your own code. Message will not be deleted and be pushed again
  22. console.log(err)
  23. })