查詢時間段内發送的短訊結果

GET

https://api.laaffic.com/v3/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.laaffic.com/v3/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
成功 發送成功的條數 String
fail 發送失敗的條數 String
array 找到發送結果的json集合 JSONArray
msgId 提交號碼對應平臺,msgld String
number 提交號碼 String
receiveTime 發送時間,ISO8601標準時間格式UrlEncode(2021-02-12T23:59:59+08:00) String
status 發送狀態:0:發送成功,2:發送失敗 String
 
響應狀態碼
狀態碼 説明
0 成功
-1 認證錯誤
-2 IP訪問受限
-11 定時時間格式不對
-16 超出時間限制
-18 接口異常
-19 請聯係業務經理綁定通道
 

語言

Java

PHP

請求

package com.laaffic.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.laaffic.com/v3";
    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);
    }
}        
                

請求

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.laaffic.com/v3/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);        
                
 

響應示例

{
    "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"
        }
    ]
}                    
                

點擊此處開啟人工服務