单条发送接口

POST URL https://api.liasmart.com/api/SendSMS

参数说明

参数名称 必选项 参数描述 举例
api_id Email或者用户后台中提示的APIID API43404236
api_password Email或者用户后台中提示的API密码 Password
sms_type 短信类型 填写P,T 填写字符P表示营销短信,字符T表示事务类短信
encoding 短信编码方式 填写T,U 填写字符T表示拉丁字符,字符U表示Unicode (主要为中文,日文,韩文等使用)
sender_id 发送方ID 您注册的Sender ID
phonenumber 手机号码 接收人手机号码,格式为国家码+手机号 例如中国的手机号,可填写8613912345678
textmessage 短信内容 在模板ID未携带时,必须填写短信内容。
uid 可选 用户指定短信ID 在DLR中回填。该短信在您业务系统内的ID,如短信发送记录流水号。
callback_url 可选 状态报告接收URL 将向这个地址推送运营商返回的状态报告。

API举例

GET请求

 
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.liasmart.com/api/SendSMS?api_id=API4623444906&api_password=password@123&sms_type=P&encodin g=T&sender_id=LIASMART&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.liasmart.com/api/SendSMS?api_id=API4623444906&api_password=password@123&sms_type=P&encodin g=T&sender_id=LIASMART&phonenumber=8613333333333&textmessage=test")
  .method("GET", null)
  .build();
Response response = client.newCall(request).execute();
 
curl --location --request GET 'https://api.liasmart.com/api/SendSMS?api_id=API4623444906&api_password=password@123&sms_type=P&encoding=T&sender_id=LIASMART&phonenumber=8613333333333&textmessage=test'
 
import http.client

conn = http.client.HTTPSConnection("api.liasmart.com")
payload = ''
headers = {}
conn.request("GET", "/api/SendSMS?api_id=API4623444906&api_password=password@123&sms_type=P&encodin g=T&sender_id=LIASMART&phonenumber=8613333333333&textmessage=test", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

POST请求

 
<?php

$url = "https://api.liasmart.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":"【利亚智联】您的验证码是112233,5分钟内有效。"
}
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.liasmart.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":"【利亚智联】您的验证码是112233,5分钟内有效。"
}`;

xhr.send(data);
 
#!/bin/bash

curl -X POST https://api.liasmart.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":"【利亚智联】您的验证码是112233,5分钟内有效。"
}
DATA

 
import requests
from requests.structures import CaseInsensitiveDict

url = "https://api.liasmart.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":"【利亚智联】您的验证码是112233,5分钟内有效。"
}
"""


resp = requests.post(url, headers=headers, data=data)

print(resp.status_code)

GET和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
}

响应参数说明

参数名称 说明
message_id 系统生成的短信ID
status s=提交成功 F=提交失败
remarks 状态描述
uid 您在提交时填写的uid,若未填写,则返回null

联系销售