参数 | 说明 | 是否必填 | 类型 |
---|---|---|---|
appId | 应用id | 是 | String |
templateId | 模板id | 否 | String |
languageCode | 模板语言,详见国家枚举 | 否 | String |
Request URL:
https://api.itniotech.com/wa/template/query
Request Method:
POST
Request Headers:
Content-Type: application/json;charset=UTF-8
Sign: 05d7a50893e22a5c4bb3216ae3396c7c
Timestamp: 1630468800
Api-Key: bDqJFiq9
Request Body:
{
"appId":"xJdRmKR3ff",
"templateId":"e66a5e3780d54b02adf1c280c10e90dd",
"languageCode":"zh_CN"
}
参数 | 说明 | 类型 |
---|---|---|
status | 状态码,0成功,其他失败参见响应状态码说明 | String |
reason | 原因说明 | String |
data | 发送结果 | Object |
appId | 应用id | String |
templateId | 模板id | String |
templateName | 模板名称 | String |
templateCategory | 模板类型:0-AUTHENTICATION(身份验证);1-MARKETING(营销性);1-MARKETING(营销性);2-UTILITY(交易类)。 | Integer |
templateLanList | 模板列表,里面包含多种不同语言模板 | List |
status | 模板状态:PENDING(审核中)、REJECTED(审核未通过)、APPROVED(审核通过)、DELETED(已删除)、DISABLED(禁用)、PENDING_DELETION(待删除)、IN_APPEAL(已提出上诉)、PAUSED(暂时停用)、LIMIT_EXCEEDED(超出限制)、FLAGGED(计划禁用)、REINSTATED(恢复) | String |
reason | 拒绝原因 | String |
footer | 页脚内容 | String |
language | Object | |
code | 语言编码 | String |
nameEn | 英文描述 | String |
nameCn | 中文描述 | String |
header | Object | |
type | 头部类型,0-TEXT | Integer |
text | format=1时,是页眉的文本内容 | String |
example | 页眉变量示例 | Array |
body | Object | |
type | body正文类型,0-TEXT | String |
text | 正文内容 | String |
exampleParams | 对应变量数组 | Array |
buttons | Object | |
type | 按钮类型:3-OTP(模板类型为身份验证时可选)目前仅支持otp类型,默认3 | Integer |
text | 内容 | String |
otp_type | 表示按钮类型,type为3必填,验证码按钮类型:copyCode(复制验证码),如需让模板使用复制验证码按钮,请将此占位符设为"COPY_CODE" | String |
status | 状态说明 |
---|---|
0 | 成功 |
-1 | 身份验证错误 |
-2 | 模板状态不正确 |
-4 | 时间戳过期 |
-5 | 系统异常 |
-6 | IP受限 |
-7 | 参数校验异常 |
-8 | 参数校验异常 |
-10 | 应用不存在 |
-11 | 应用名称已存在 |
-12 | 网络异常,请稍后重试 |
-14 | 账号未认证 |
Java
PHP
REQUEST
package com.itniotech.api.demo.im;
import cn.hutool.core.map.MapUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
private static void queryTemplateInfo() {
final String baseUrl = "https://api.itniotech.com/wa/";
final String apiKey = "your api key";
final String apiPwd = "your api secret";
final String appId = "your appid";
final String templateId = "template id"; //the template id
final String url = baseUrl.concat("template/query");
HttpRequest request = HttpRequest.post(url);
final String datetime = String.valueOf(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().getEpochSecond());
final String sign = SecureUtil.md5(apiKey.concat(apiPwd).concat(datetime));
request.header(Header.CONNECTION, "Keep-Alive")
.header(Header.CONTENT_TYPE, "application/json;charset=UTF-8")
.header("Sign", sign)
.header("Timestamp", datetime)
.header("Api-Key", apiKey);
String body = JSONUtil.createObj()
.set("appId", appId)
.set("templateId", templateId)
.toString();
HttpResponse response = request.body(body).execute();
if (response.isOk()) {
String result = response.body();
System.out.println(result);
}
}
REQUEST
header('content-type:text/html;charset=utf8');
$apiKey = "your api key";
$apiSecret = "your api secret";
$appId = "your appid";
$timeStamp = time();
$sign = md5($apiKey.$apiSecret.$timeStamp);
$headers = array('Content-Type:application/json;charset=UTF-8',"Sign:$sign","Timestamp:$timeStamp","Api-Key:$apiKey");
$url = "https://api.itniotech.com/wa/template/query";
$dataArr["appId"] = $appId;
$dataArr["templateId"] = "template id";
$data = json_encode($dataArr);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_POSTFIELDS , $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$output = curl_exec($ch);
curl_close($ch);
var_dump($output);
RESPONSEEXAMPLE
{
"status": "0",
"reason": "success",
"data": [
{
"appId": "xJdRmKR3ff",
"templateId": "3654e6b0218548a3ae20e4f9db7f5a4d",
"templateName": "discount_promotion",
"templateCategory": 1,
"templateLanList": [
{
"language": {
"nameCn": "英语",
"nameEn": "English",
"code": "en"
},
"header": {
"type": 0,
"text": "New Zhengde supermarket"
},
"body": {
"type": 0,
"text": "The new Zhengde supermarket has started a crazy sale, all the products are {{#}}% off...",
"exampleParams": [
"50"
]
},
"footer": "Zhengde Business",
"status": "APPROVED",
"reason": "APPROVED"
}
]
}
]
}