logo
logo
请输入关键词搜索产品或者文档
中国

中国站

创蓝云智

国际站

Innopaas

首页Downstream SMS Docking Interface

Downstream SMS Docking Interface

更新时间:2023-12-19T15:16:42

1.1 Protocol Description

NameDescription
ProtocolHTTP POST
Encoding formatUTF8
Content-Typeapplication/json
URLhttp://intapi.sgap.253.com/send/sms

1.2 Request Header

NameTyperequiredExampleExplanation
signstring1234abcd7890qwerPlease generate a signature based on the signing method provided
noncestring1653043349000timestamp

1.3Request package

NameTyperequiredExampleExplanation
accountstringI6000000API account, maximum 50 characters.
mobilestring8615800000000Phone number, format (area code + phone number), for example: 8615800000000, where 86 is the area code for China, and 15800000000 is the actual phone number to receive the SMS. The area code should not start with 00, and the phone number should be 5-20 characters.
msgstring【InnoPaaS】Your verification code is:2530The SMS content length should not exceed 536 characters. If unsubscribe is enabled, append the unsubscribe link (2ub.co/xxxxxx or 1ub.co/xxxxxx) to the end of the SMS content. This will add 14 characters to the original SMS content and may increase the billing SMS count.
senderIdstringSENDER0The sender name displayed to the user after they receive the SMS is not customizable in China. It may be customizable in other countries, but registering with the local carrier in advance is required. Please confirm the details with the InnoPaaS contact person.
uidstring123456Custom batch number provided by client, maximum 64 characters.
tdFlagint1A flag indicating whether unsubscribe is enabled. 1 for enabled, 0 or null for disabled.

Signing Method:

  1. Sort the parameter names (excluding the password) in ascending order according to the ASCII code table.
  2. Combine the non-empty parameter names and their values in the order of step 1, with no extra characters in the combination.
  3. Append the password to the end of the combined string from step 2 to generate the signature string.
  4. Convert the signature string to a lowercase MD5 encryption string as the value of the "sign" field in the request headers.

1.4 Response body

NameTypeExampleExplanation
codestring0Status code: 0 for success, non-zero for failure.
errorstringsignature errorStatus code description, successful return of empty string
msgidstring17041010383624511message id

Note: "code" refers to the response status code, which can be compared with the submitted response status code.

1.5 Example of adding signature code

复制成功
```java
package com.angi;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.DigestUtils;

import java.util.Map;
import java.util.TreeMap;


/**
*  Parameter signing and verification
*/
public class SignUtil {

   private static final String SIGN = "sign";

   /**
    * Send signature 
    */
   public static String sendSign(String password, TreeMap<String, String> paramMap) {
       paramMap.remove(SIGN);
       StringBuilder sb = new StringBuilder();
       for (Map.Entry<String, String> entry : paramMap.entrySet()) {
           if (StringUtils.isNotBlank(entry.getValue())) {
               sb.append(entry.getKey());
               sb.append(entry.getValue());
           }
       }
       return DigestUtils.md5DigestAsHex((sb.toString() + password).getBytes()).toLowerCase();
   }

   /**
    * Send signature 
    */
   public static boolean verifySendSign(String password, TreeMap<String, String> paramMap) {
       String sign = paramMap.remove(SIGN);
       String computed = sendSign(password, paramMap);
       return StringUtils.equals(sign, computed);
   }


   public static void main(String[] args) {
       /**Send signature verification*/
       String password = "4Z7bMS1eLI6895";
       TreeMap<String, String> paramMap = new TreeMap<>();
       paramMap.put("nonce", "222222");
       paramMap.put("account", "IM6742671");
       paramMap.put("mobile", "8618916198813");
       paramMap.put("msg", "test 666661 ");
       System.out.println(JSONObject.toJSONString(paramMap));
       String sign = sendSign(password, paramMap);
       System.out.println(sign);

       TreeMap<String, String> newParamMap = new TreeMap<>(paramMap);
       newParamMap.put(SIGN, sign);

       boolean validate = verifySendSign(password, newParamMap);
       System.out.println(validate);

   }
}
没有更多了
没有上一篇
没有下一篇
文档目录
收缩
24小时热线 400-9669-253