Single sending interface
POST URL https://api.HAORUI.com/api/SendSMS
Parameter Description
Parameter name | Required | Parameter description | give an example |
api_id | Yes | APIID prompted in email or user background | API43404236 |
---|---|---|---|
api_password | Yes | API password prompted in email or user background | Password |
sms_type | Yes | SMS type | Fill in P, T, the character P represents marketing SMS, and the character T represents transaction SMS |
encoding | Yes | SMS encoding method | Fill in T, U, the character T represents Latin characters, and the character U represents Unicode (mainly used in Chinese, Japanese, Korean, etc.) |
sender_id | Yes | Sender ID | Your registered Sender ID |
phonenumber | Yes | phone number | The recipient's mobile phone number, in the format of country code+mobile phone number, such as China's mobile phone number, can be filled in 8613912345678 |
textmessage | Yes | SMS content | When the template ID is not carried, the message content must be filled in。 |
uid | Optional | User specified SMS ID | Backfill in DLR. The ID of the message in your business system, such as the serial number of the message sending record. |
callback_url | Optional | Status report receiving URL | The status report returned by the operator will be pushed to this address. |
API example
GET request
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.HAORUI.com/api/SendSMS?api_id=API4623444906&api_password=password@123&sms_type=P&encodin g=T&sender_id=HAORUI&phonenumber=8613333333333&textmessage=test');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.HAORUI.com/api/SendSMS?api_id=API4623444906&api_password=password@123&sms_type=P&encodin g=T&sender_id=HAORUI&phonenumber=8613333333333&textmessage=test")
.method("GET", null)
.build();
Response response = client.newCall(request).execute();
curl --location --request GET 'https://api.HAORUI.com/api/SendSMS?api_id=API4623444906&api_password=password@123&sms_type=P&encoding=T&sender_id=HAORUI&phonenumber=8613333333333&textmessage=test'
import http.client
conn = http.client.HTTPSConnection("api.HAORUI.com")
payload = ''
headers = {}
conn.request("GET", "/api/SendSMS?api_id=API4623444906&api_password=password@123&sms_type=P&encodin g=T&sender_id=HAORUI&phonenumber=8613333333333&textmessage=test", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
POST请求
<?php
$url = "https://api.HAORUI.com/api/SendSMS";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$data = <<<DATA
{
"api_id":"YourApiId",
"api_password":"YourApiPassword",
"sms_type": "T",
"encoding": "U",
"sender_id":"LIASMT",
"phonenumber":"8613312345678",
"textmessage":"[LIASMART] Your verification code is 112233, which is valid within 5 minutes."
}
DATA;
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);
?>
var url = "https://api.HAORUI.com/api/SendSMS";
var xhr = new XMLHttpRequest();
xhr.open("POST", url);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log(xhr.status);
console.log(xhr.responseText);
}};
var data = `{
"api_id":"YourApiId",
"api_password":"YourApiPassword",
"sms_type": "T",
"encoding": "U",
"sender_id":"LIASMT",
"phonenumber":"8613312345678",
"textmessage":"[LIASMART] Your verification code is 112233, which is valid within 5 minutes."
}`;
xhr.send(data);
#!/bin/bash
curl -X POST https://api.HAORUI.com/api/SendSMS -H "Content-Type: application/json" --data-binary @- <<DATA
{
"api_id":"YourApiId",
"api_password":"YourApiPassword",
"sms_type": "T",
"encoding": "U",
"sender_id":"LIASMT",
"phonenumber":"8613312345678",
"textmessage":"[LIASMART] Your verification code is 112233, which is valid within 5 minutes."
}
DATA
import requests
from requests.structures import CaseInsensitiveDict
url = "https://api.HAORUI.com/api/SendSMS"
headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/json"
data = """
{
"api_id":"YourApiId",
"api_password":"YourApiPassword",
"sms_type": "T",
"encoding": "U",
"sender_id":"LIASMT",
"phonenumber":"8613312345678",
"textmessage":"[LIASMART] Your verification code is 112233, which is valid within 5 minutes."
}
"""
resp = requests.post(url, headers=headers, data=data)
print(resp.status_code)
Response from GET and POS
{
"message_id": 26471304,
"status": "S",
"remarks": "Message Submitted Sucessfully",
"uid": null
}
{
"message_id": 26471304,
"status": "S",
"remarks": "Message Submitted Sucessfully",
"uid": null
}
{
"message_id": 26471304,
"status": "S",
"remarks": "Message Submitted Sucessfully",
"uid": null
}
{
"message_id": 26471304,
"status": "S",
"remarks": "Message Submitted Sucessfully",
"uid": null
}
Response parameter description of GET and POS
Parameter name | explain |
message_id | SMS ID generated by the system |
---|---|
status | S=submission succeeded F=submission failed |
remarks | Status description |
uid | The uid you filled in when submitting. If it is not filled in, null will be returned |