开发者社区> 问答> 正文

短信查询API(QuerySendDetails)---Node.js



短信发送记录查询接口(QuerySendDetails)


用于查询短信发送的状态,是否成功到达终端用户手机

入参列表

参数名称参数类型必填与否样例取值参数说明
PhoneNumberString必须15000000000短信接收号码
BizIdString可选1234^1234发送流水号,从调用发送接口返回值中获取
SendDateString必须20170525短信发送日期格式yyyyMMdd,支持最近30天记录查询
PageSizeNumber必须10页大小Max=50
CurrentPageNumber必须1当前页码


出参列表

出参名称出参类型样例取值参数说明
RequestIdString8906582E-6722请求ID
CodeStringOK状态码-返回OK代表请求成功,其他错误码详见错误码列表
MessageString请求成功状态码的描述
TotalCountNumber100发送总条数
TotalPageNumber10总页数
smsSendDetailDTOsObject-发送明细结构体,详见Demo样例


Demo样例

出参名称出参类型样例取值参数说明
phoneNumString13000000000手机号码
sendStatusNumber1发送状态 1:等待回执,2:发送失败,3:发送成功
errCodeStringDELIVERED运营商短信错误码
templateCodeStringSMS_000模板ID
contentString【阿里云】你好!短信内容
sendDateObject2017-05-25 00:00:00发送时间
receiveDateString2017-05-25 00:00:00接收时间
outIdString123外部流水扩展字段


技术对接步骤



1:下载SDK工具包

<divre style='background: rgb(246, 246, 246); font: 12px/1.6 "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; margin: 0px 0px 16px; padding: 10px; outline: 0px; border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(51, 51, 51); text-transform: none; text-indent: 0px; letter-spacing: normal; overflow: auto; word-spacing: 0px; white-space: pre-wrap; word-wrap: break-word; box-sizing: border-box; orphans: 2; widows: 2; font-size-adjust: none; font-stretch: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;' prettyprinted?="" linenums="">
  1. $ npm install @alicloud/sms-sdk --save

SDK&DEMO[ 下载地址]

2: 编写样例程序

<pre style='background: rgb(246, 246, 246); font: 12px/1.6 "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; padding: 10px; outline: 0px; border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(51, 51, 51); text-transform: none; text-indent: 0px; letter-spacing: normal; overflow: auto; margin-top: 0px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; word-spacing: 0px; white-space: pre-wrap; word-wrap: break-word; box-sizing: border-box; orphans: 2; widows: 2; font-size-adjust: none; font-stretch: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;' prettyprinted?="" linenums="">
  1.   /**
  2. * 云通信基础能力业务短信发送、查询详情以及消费消息示例,供参考。
  3. * Created on 2017-07-31
  4. */
  5. const SMSClient = require('@alicloud/sms-sdk')
  6. // ACCESS_KEY_ID/ACCESS_KEY_SECRET 根据实际申请的账号信息进行替换
  7. const accessKeyId = 'yourAccessKeyId'
  8. const secretAccessKey = 'yourAccessKeySecret'
  9. //初始化sms_client
  10. let smsClient = new SMSClient({accessKeyId, secretAccessKey})
  11. //查询短信发送详情
  12. smsClient.queryDetail({
  13.     PhoneNumber: '1500000000',
  14.     SendDate: '20170731',
  15.     PageSize: '10',
  16.     CurrentPage: "1"
  17. }).then(function (res) {
  18.     let {Code, SmsSendDetailDTOs}=res
  19.     if (Code === 'OK') {
  20.         //处理发送详情内容
  21.         console.log(SmsSendDetailDTOs)
  22.     }
  23. }, function (err) {
  24.     //处理错误
  25.     console.log(err)
  26. })

展开
收起
nicenelly 2017-10-25 11:50:55 2413 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
CUDA MATH API 立即下载
API PLAYBOOK 立即下载
传统企业的“+互联网”-API服务在京东方的实践 立即下载