SmsUp
You can specify an HTTP URL to receive mobile originated messages from users. When a user replies to a text message, the platform pushes the message to the HTTP URL that you provide. You must accept the message and respond in the required format.
Usage notes
To receive mobile originated messages, go to the Short Message Service console, enable the HTTP batch push pattern for Mobile Originated Message, and configure a receiving address. For more information about receipt message configuration, see Receipt message configuration.
Parameter description
The parameters are in a JSON array format. A single request can contain multiple mobile originated messages.
Protocol description
Parameter | Description |
Request protocol | HTTP |
Request format | application/json |
Encoding | UTF-8 |
Parameter example
[
{
"phone_number" : "1381111****",
"content" : "Content",
"send_time" : "2017-09-01 00:00:00",
"dest_code" : "1234",
"sequence_id" : "1234567890"
}
]Field description
Name | Type | Required | Example | Description |
phone_number | String | Yes | 138****1111 | Mobile phone number. |
content | String | Yes | Content | Message content. |
send_time | String | Yes | 2017-09-01 00:00:00 | Push time for the carrier uplink. |
dest_code | String | Yes | 1234 | The extension number for the mobile originated message. The system generates this number automatically. You cannot specify a custom value. |
sequence_id | String | Yes | 1234567890 | Serial number. |
Response description
After your HTTP address receives the request parameters, you must respond in the following format.
Response example
{
"code" : 0,
"msg" : "Accepted successfully"
}Field description
Name | Type | Required | Example | Description |
code | Number | Yes | 0 | Acknowledgement code. The system only checks if the code is a number and does not validate its content. |
msg | String | No | Accepted successfully | Description. |
If the HTTP status code is 200, the request is successful. If the HTTP status code is not 200 or a timeout occurs, the system retries the push.
If a system error or consumption failure occurs, return an HTTP 50X status code.
Push retries
If a push fails, the system retries after 1 minute, 5 minutes, and 10 minutes. If the push still fails after these three attempts, the system does not retry.
Example of receiving a mobile originated message
@PostMapping("/resMsg")
public JSONObject resMsg(@RequestBody JSONArray array) {
// TODO: Process the mobile originated message content. This example only prints the receipt information.
System.out.println(array.toJSONString());
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", "Accepted successfully");
return json;
}