查询时间段内发送的短信结果

GET
https://api.itniotech.com/sms/getSentRcd?appId={appId}&startTime={startTime}&endTime={endTime}&startIndex={startIndex}
查询开始时间到结束时间这个时间段内已经发送完成的短信结果,支持查询最近90天的短信记录,最大查询时间区间为31天。
 
请求参数
appId
String
必填
应用id(短信-短信应用)
startTime
String
必填
查询开始时间,ISO8601标准时间格式 UrlEncode(2021-02-12T00:00:00+08:00)
endTime
String
必填
查询结束时间,ISO8601标准时间格式 UrlEncode(2021-02-12T23:59:59+08:00)
startIndex
Int
查询的起始下标(默认0,。单次查询默认最多返回50000个结果,超过50000分多次查询时可用到此字段)
 
请求示例
Request URL:
    https://api.itniotech.com/sms/getSentRcd?appId=4luaKsL2&startTime=2021-02-12T00%3A00%3A00%2B08%3A00&endTime=2021-02-12T23%3A59%3A59%2B08%3A00&startIndex=0
Request Method:
    GET
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
 
响应参数
参数 说明 类型
status 状态码,0成功,其他失败参见响应状态码说明 String
reason 失败原因说明 String
success 发送成功的条数 String
fail 发送失败的条数 String
array 找到发送结果的json集合 JSONArray
msgId 提交号码对应平台msgId String
number 提交号码 String
receiveTime 发送时间,ISO8601标准时间格式(2021-02-12T09:30:03+08:00) String
status 发送状态:0发送成功,-1:发送中,1:发送失败(不包含队列中的短信) String
 
响应状态码
status 状态说明
0 成功
-1 认证错误
-2 Ip访问受限
-11 定时时间格式不对
-16 超出时间范围限制
-18 端口程序异常
-19 联系商务发送短信报价
 

LANGUAGE

Java

PHP

REQUEST

package com.itniotech.api.demo.sms;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

private void getSentRcd() {
    final String baseUrl = "https://api.itniotech.com/sms";
    final String apiKey = "your api key";
    final String apiPwd = "your api secret";
    final String appId = "{{appId}}";
    final String startTime = URLEncoder.encode("{{startTime}}");
    final String endTime =  URLEncoder.encode("{{endTime}}");
    final String startIndex = "{{startIndex}}";
    final String url = baseUrl.concat("/getSentRcd");
    final CharSequence getSentRcdTemplate = "?appId={}&startTime={}&endTime={}&startIndex={}";
    HttpRequest request = HttpRequest.get(url.concat(StrUtil.format(getSentRcdTemplate, appId, startTime, endTime, startIndex)));

    // currentTime
    final String datetime = String.valueOf(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().getEpochSecond());
    // generate md5 key
    final String sign = SecureUtil.md5(apiKey.concat(apiPwd).concat(datetime));
    request.header(Header.CONNECTION, "Keep-Alive")
    .header(Header.CONTENT_TYPE, "application/json;charset=UTF-8")
    .header("Sign", sign)
    .header("Timestamp", datetime)
    .header("Api-Key", apiKey);
    HttpResponse response = request.execute();
    if (response.isOk()) {
        String result = response.body();
        System.out.println(result);
    }
} 

REQUEST

header('content-type:text/html;charset=utf8');

$apiKey = "your api key";
$apiSecret = "your api secret";
$appId = "{{appId}}";

$startTime = urlencode("{{startTime}}");
$endTime = urlencode("{{endTime}}");
$startIndex = "{{startIndex}}";

$url = "https://api.itniotech.com/sms/getSentRcd?appId=$appId&startTime=$startTime&endTime=$endTime&startIndex=$startIndex";
$timeStamp = time();
$sign = md5($apiKey.$apiSecret.$timeStamp);
$headers = array('Content-Type:application/json;charset=UTF-8',"Sign:$sign","Timestamp:$timeStamp","Api-Key:$apiKey");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

$output = curl_exec($ch);
curl_close($ch);
var_dump($output);
 

RESPONSEEXAMPLE

{
    "status":"0",
    "reason":"success",
    "success":"2",
    "fail":"0",
    "array":[
    {
        "msgId":"2108021054011000095",
        "number":"91856321412",
        "receiveTime":"2023-06-12T09:30:03+08:00",
        "status":"0"
    },
    {
        "msgId":"2108021059531000096",
        "number":"91856321413",
        "receiveTime":"2023-06-12T09:30:03+08:00",
        "status":"0"
    }]
}