1.1 Protocol Description
1.2 Request Header
Name | Type | required | Example | Explanation |
---|
sign | string | 是 | 1234abcd7890qwer | Please generate a signature based on the signing method provided |
nonce | string | 是 | 1653043349000 | timestamp |
1.3Request package
Name | Type | required | Example | Explanation |
---|
account | string | 是 | I6000000 | API account, maximum 50 characters. |
mobile | string | 是 | 8615800000000 | Phone 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. |
msg | string | 是 | 【InnoPaaS】Your verification code is:2530 | The 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. |
senderId | string | 否 | SENDER0 | The 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. |
uid | string | 否 | 123456 | Custom batch number provided by client, maximum 64 characters. |
tdFlag | int | 否 | 1 | A flag indicating whether unsubscribe is enabled. 1 for enabled, 0 or null for disabled. |
Signing Method:
- Sort the parameter names (excluding the password) in ascending order according to the ASCII code table.
- Combine the non-empty parameter names and their values in the order of step 1, with no extra characters in the combination.
- Append the password to the end of the combined string from step 2 to generate the signature string.
- 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
Name | Type | Example | Explanation |
---|
code | string | 0 | Status code: 0 for success, non-zero for failure. |
error | string | signature error | Status code description, successful return of empty string |
msgid | string | 17041010383624511 | message 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;
public class SignUtil {
private static final String SIGN = "sign";
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();
}
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) {
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);
}
}
没有更多了