通过模板发送

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
templateid 如选择通过模板发送,请在此填写模板ID 模板ID可在用户Portal中查询,比如10
V1 可选 模板变量1 模板中使用V1~V5作为变量名称,此处填写V1的值
V2 可选 模板变量2 模板中使用V1~V5作为变量名称,此处填写V2的值

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&templateid=10&V1=123456');
$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&templateid=10&V1=123456")
  .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&templateid=10&V1=123456'
 
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&templateid=10&V1=123456", 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(
   "Accept: */*",
   "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",
 "templateid":"10",
  "V1":"123456"
}
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("Accept", "*/*");
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",
 "templateid":"10",
  "V1":"123456"
}`;

xhr.send(data);

 
#!/bin/bash

curl -X POST https://api.liasmart.com/api/SendSMS -H "Accept: */*" -H "Content-Type: application/json" --data-binary @- <<DATA
{
  "api_id":"YourApiId",
  "api_password":"YourApiPassword",
 "sms_type": "T",
 "encoding": "U",
 "sender_id":"LIASMT",
 "phonenumber":"8613312345678",
 "templateid":"10",
  "V1":"123456"
}
DATA

 
import requests
from requests.structures import CaseInsensitiveDict

url = "https://api.liasmart.com/api/SendSMS"

headers = CaseInsensitiveDict()
headers["Accept"] = "*/*"
headers["Content-Type"] = "application/json"

data = """
{
  "api_id":"YourApiId",
  "api_password":"YourApiPassword",
 "sms_type": "T",
 "encoding": "U",
 "sender_id":"LIASMT",
 "phonenumber":"8613312345678",
 "templateid":"10",
  "V1":"123456"
}
"""


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 系统生成的短信ID1
status s=提交成功 F=提交失败
remarks 状态描述
uid 您在提交时填写的uid,若未填写,则返回null

联系销售