本文为您介绍了Node.js调用QueryMessage查看短信状态。

请求参数

名称 类型 是否必选 示例值 描述
MessageId String 1008***3003003 短信发送ID。

返回数据

名称 类型 示例值 描述
ResponseCode String OK 短信提交的状态。
ResponseDescription String The SMS Send Request was accepted 短信提交状态的详细描述。
To String 6581177810 发送号码。
Status Number 1 短信的发送状态:
  • 1(Submitted)
  • 2(Failed)
  • 3(Delivered)
ErrorCode String DELIVERED 短信的发送状态码。
ErrorDescription String success 短信发送状态码的详细描述。
Message String Hello! 短信内容。
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 号码所属的运营商网络。

引入阿里云核心包

  • 方法1:通过npm/yarn安装。
    npm install @alicloud/pop-core
                        
  • 方法2:core-sdk下载地址:Node.js API SDK

调用示例

  • RegionId必须为ap-southeast-1,请勿修改。
  • endpoint必须为https://dysmsapi.ap-southeast-1.aliyuncs.com, 请勿修改。
  • apiVersion必须为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);
})