Batch Sending Multi Content SMS

POST

https://api.itniotech.com/sms/sendSms/batch

Batch sending multi content SMS interface.
 
Request Parameters
Parameters Description Required Type
appId App ID (SMS-SMS APP) Yes String
array Json gather Yes Array
numbers SMS Receiving Phone Number(COMMA required between each phone number) Yes String
content SMS content, length should not be over the 1024 characters.(GET should use urlEncode) Yes String
senderId sender number(name). The maximum length is 32 characters. No String
orderId Customer message id. The number of orderId must be consistent with the number of mobile phone numbers. No String
 
Request Sample
Request URL: 
    https://api.itniotech.com/sms/sendSms/batch
Request Method: 
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
    "appId": "4luaKsL2",
    "array": [
        {
            "numbers": "91856321412,91856321413",
            "content": "test message",
            "senderId": "",
            "orderId": "56584,56585"
        },
        {
            "numbers": "91856321414",
            "content": "test message1",
            "senderId": "",
            "orderId": "56586"
        }
    ]
}
 
Response Parameters
Parameters Description Type
status "0" means successful,others than 0 means failure, seeing Status Code description. String
reason failure reason description String
success The number of Numbers in the submitted successfully String
fail The number of Numbers in the submitted fails String
array Json gather JSONArray
msgId submitted numbers id corresponding to platform String
number submitted numbers String
orderId customer id String

Note: After the SMS is successfully submitted and sent, the system will generate a platform msgId for each successfully submitted number. Customers can query the sending results of the number basing on the msgId.

 
Response Status Code
status Description
0 success
-1 Authentication error
-2 Restricted IP access
-3 Sensitive characters in SMS content
-4 SMS content is empty
-5 The SMS content is too long
-6 SMS that is not a template
-7 Phone number exceeds limit
-8 The phone number is empty
-9 Abnormal phone number
-10 The customer's balance is insufficient
-16 Timestamp expires
-18 port program unusual
-19 Please contact the business managers binding channel
 

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 batchSendSms() {
    final String baseUrl = "https://api.itniotech.com/sms";
    final String apiKey = "your api key";
    final String apiPwd = "your api secret";
    final String appId = "your appid";

    Map map=new HashMap<>();
    map.put("numbers","91856321412,91856321413");
    map.put("content","hello world");
    map.put("orderId","56584,56585");
    final String url = baseUrl.concat("/sendSms/batch");

    HttpRequest request = HttpRequest.post(url);

    // 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);

    final String params = JSONUtil.createObj()
            .set("appId", appId)
            .set("array", Arrays.asList(map))
            .toString();

    HttpResponse response = request.body(params).execute();
    if (response.isOk()) {
        String result = response.body();
        System.out.println(result);
    }
}
        
                

REQUEST

$apiKey = "your api key";
$apiSecret = "your api secret";
$appId = "your appid";
$url = "https://api.itniotech.com/sms/sendSms/batch";
$timeStamp = time();
$sign = md5($apiKey.$apiSecret.$timeStamp);

$dataArr['appId'] = $appId;
$dataArr['array'] = array(
    array(
        'numbers' => '91856321412,91856321413',
        'content' => 'hello world',
        'orderId' => '56584,56585',
    )
);

$data = json_encode($dataArr);
$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_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_POSTFIELDS , $data);
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": "2207201629421000001",
            "number": "91856321412",
            "orderId": "56584"
        },
        {
            "msgId": "2207201629421000002",
            "number": "91856321413",
            "orderId": "56585"
        }
    ]
}