本文为您介绍短信服务SMS回执API,Node.js参数说明。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
MessageType | String | 是 | SmsReport | 有一种消息类型:SmsReport。 |
QueueName | String | 是 | Alicom-Queue-xxxxxx-SmsReport | 阿里巴巴提供的消息队列名称,在短信控制台--系统设置可以查看到。 |
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
MessageId | String | 100803***03003 | 短信的发送ID。 |
To | String | 45***0121 | 短信的发送号码。 |
Status | Number | 3 | 短信的发送状态:
|
ErrorCode | String | success | 短信发送返回的错误码。 |
ErrorDescription | String | success | 短信发送返回的错误码详细描述。 |
SendDate | String | Mon, 24 Dec 2018 16:58:22 +0800 | 短信转发给运营商的时间。 |
ReceiveDate | String | Mon, 24 Dec 2018 16:58:22 +0800 | 短信收到运营商回执的时间。 |
NumberDetail | String | 号码的详细属性。 | |
└Country | String | Hongkong, China | 号码所属国家。 |
└Region | String | HongKong | Number Region。 |
└Carrier | String | CMI | 号码所属的运营商网络。 |
引入阿里云核心包
SDK下载:点击查看下载链接。
调用示例
/**
* 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)
})