Get Report
https://api.itniotech.com/sms/getReport?appId={appId}&msgIds={msgIds}
Request URL:
https://api.itniotech.com/sms/getReport?appId=4luaKsL2&msgIds=2108021054011000095,2108021059531000096
Request Method:
GET
Request Headers:
Content-Type: application/json;charset=UTF-8
Sign: 05d7a50893e22a5c4bb3216ae3396c7c
Timestamp: 1630468800
Api-Key: bDqJFiq9
Parameters | Description | Type |
---|---|---|
status | "0"means successful,others than 0 means failure, seeing Status Code description. | String |
reason | Failure reason description | String |
success | Number of successful submitted messages | String |
fail | Number of failure submitted messages | String |
sending | Number of sending messages | String |
nofound | The number of nofound messages by ID(Contains SMS messages in the queue) | String |
array | Json array with submission results | JSONArray |
msgId | Submitted numbers id corresponding to platform | String |
number | Submitted nunbers | String |
receiveTime | Receive time ISO8601 standard tine format (2021-02-12T09:30:03+08:00) | String |
status | Messages status:0: sent successfully, -1:sent in, 1:sent failed(Does not contain messages in the queue) | String |
status | Description |
---|---|
0 | success |
-1 | Authentication error |
-2 | Restricted IP access |
-11 | Incorrect time format |
-14 | Field is empty or query ID is abnormal |
-16 | Timestamp expires |
-18 | port program unusual |
-19 | Confirm SMS pricing with the business team |
Java
PHP
Python
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 getReport() {
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 msgIds = "{{msgIds}}";
final String url = baseUrl.concat("/getReport");
final CharSequence sendSmsTemplate = "?appId={}&msgIds={}";
HttpRequest request = HttpRequest.get(url.concat(StrUtil.format(sendSmsTemplate, appId, msgIds)));
// 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}}";
$msgIds = "{{msgIds}}";
$url = "https://api.itniotech.com/sms/getReport?appId=$appId&msgIds=$msgIds";
$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);
REQUEST
import hashlib
import time
import requests
import json
base_url = "https://api.itniotech.com/sms/"
api_key = "your api key"
api_pwd = "your api secret"
appid = "{{appId}}"
msgIds = "{{msgIds}}"
def create_headers():
timestamp = int(time.time())
s = "%s%s%s" % (api_key, api_pwd, str(timestamp))
sign = hashlib.md5(s.encode(encoding='UTF-8')).hexdigest()
headers = {
'Content-Type': 'application/json;charset=utf-8',
'Sign': sign,
'Timestamp': str(timestamp),
'Api-Key': api_key
}
return headers
headers = create_headers()
url = "%s/getReport" % base_url
print(url)
params = {"appId": appid, "msgIds": "8613000000000,8613000000001"}
print(params)
rsp = requests.get(url, params, headers=headers)
if rsp.status_code == 200:
res = json.loads(rsp.text)
print(res)
RESPONSEEXAMPLE
{
"status": "0",
"reason": "success",
"success": "2",
"fail": "0",
"sending": "0",
"nofound": "0",
"array": [
{
"msgId": "2108021054011000095",
"number": "91856321412",
"receiveTime": "2021-02-12T09:30:03+08:00",
"status": "0"
},
{
"msgId": "2108021059531000096",
"number": "91856321413",
"receiveTime": "2021-02-12T09:30:03+08:00",
"status": "0"
}
]
}