查询短信记录
查询短信记录
接口应在服务器端调用,详细说明参见服务端API。
本接口支持云调用。需开发者工具版本 >=
1.02.1904090
(最新稳定版下载),wx-server-sdk
>=0.4.0
接口说明
接口英文名
describeSmsRecords
功能描述
该接口用于查询 2 个月内的短信记录。
调用方式
HTTPS 调用
POST https://api.weixin.qq.com/tcb/describesmsrecords?access_token=ACCESS_TOKEN
云调用
- 出入参和HTTPS调用相同,调用方式可查看云调用说明文档
- 接口方法为: openapi.cloudbase.describeSmsRecords
第三方调用
- 调用方式以及出入参和HTTPS相同,仅是调用的token不同
- 该接口所属的权限集id为:49、64
- 服务商获得其中之一权限集授权后,可通过使用authorizer_access_token代商家进行调用
请求参数
属性 | 类型 | 必填 | 说明 |
---|---|---|---|
access_token | string | 是 | 接口调用凭证,该参数为 URL 参数,非 Body 参数。使用access_token或者authorizer_access_token |
EnvId | string | 是 | 环境 ID |
StartDate | string | 是 | 开始日期, 如:2021-01-01 |
EndDate | string | 是 | 结束日期, 如2021-01-07 |
Mobile | string | 是 | 电话号码 |
QueryId | string | 是 | 查询ID |
PageNumber | number | 是 | 页码(1开始) |
PageSize | number | 是 | 每页条目数 |
返回参数
属性 | 类型 | 说明 | |
---|---|---|---|
SmsRecords | array | 发送记录列表 | |
属性类型说明Mobilestring手机号码Contentstring短信内容ContentSizenumber短信内容长度Feenumber计费条数CreateTimestring发送时间ReceivedTimestring用户接收时间Statusstringsent(成功), error(失败)Remarksstring备注 | |||
TotalCount | number | 记录总数 | |
RequestId | string | 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 | |
errcode | number | 错误码 | |
errmsg | string | 错误信息 |
调用示例
示例说明: HTTPS调用
请求数据示例
{
"PostData": {
"StartDate":"2021-03-01",
"EndDate":"2021-03-23",
"EnvId":"xxx",
"QueryId":"xxx",
"PageNumber":1,
"PageSize":20
}
}
返回数据示例
{
"SmsRecords":[
{
"Content":"【XXX】XXX,跳转小程序 https://xxx/xxx 回T退订",
"ContentSize":51,
"CreateTime":"2021-03-22 17:18:37",
"Fee":1,
"Mobile":" 86xxxxxxxxxxx",
"ReceivedTime":"2021-03-22 17:18:43",
"Remarks":"用户短信接收成功",
"Status":"sent"
}
],
"TotalCount":1,
"RequestId":"bf34127a-35bd-48a2-86bb-ae583d2ff9ff"
}
示例说明: 云函数调用
请求数据示例
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
try {
const result = await cloud.openapi({ convertCase: false }).cloudbase.describeSmsRecords({
"PostData": {
"StartDate": '2021-03-01',
"EndDate": '2021-03-23',
"EnvId": 'xxx',
"QueryId": 'xxx',
"PageNumber": 1,
"PageSize": 20
}
})
return result
} catch (err) {
return err
}
}
返回数据示例
{
"Response": {
"SmsRecords": [
{
"Content": "【XXX】XXX,跳转小程序 https://xxx/xxx 回T退订",
"ContentSize": 51,
"CreateTime": "2021-03-22 17:18:37",
"Fee": 1,
"Mobile": " 86xxxxxxxxxxx",
"ReceivedTime": "2021-03-22 17:18:43",
"Remarks": "用户短信接收成功",
"Status": "sent"
}
],
"TotalCount": 1,
"RequestId": "bf34127a-35bd-48a2-86bb-ae583d2ff9ff"
},
"errMsg": "openapi.cloudbase.describeSmsRecords:ok"
}
错误码
错误码 | 错误码取值 | 解决方案 |
---|---|---|
-1 | system error | 系统繁忙,此时请开发者稍候再试 |
85088 | no qbase privilege | 该APP未开通云开发 |