首页 > API中心 > IVR群呼 > 文档指引

 
 

查询消息模板

POST
https://api.itniotech.com/wa/template/query
根据传入条件动态查询所有的模板情况
 
请求参数
参数 说明 是否必填 类型
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
markingChildType 营销模板子分类,1素材图卡轮播模板 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
headerType 轮播卡片页眉类型1(image),2(video) String
carouselButtonsType 营销轮播模板按钮类型,多个类型用逗号隔开,如1,2(1:网址跳转;2:快速回复;4:拨打电话) String
cards 轮播图卡 Array
body 正文组件对象 Object
type body正文类型,0-TEXT String
text 正文内容 String
exampleParams 对应变量数组 Array
header 页眉组件对象 Object
type 页眉类型,1(image),2(video) Integer
fileId 页眉示例文件句柄 String
buttons 按钮组件对象 Object
type 按钮类型:1:网址跳转;2:快速回复;4:拨打电话 String
text 按钮显示的名称 String
phone_number 拨打电话按钮参数:用户轻触该按钮时会拨打的电话号码 String
areaCode 拨打电话按钮参数:地区码 String
url 网址跳转按钮参数:按钮跳转网址 String
example 网址跳转按钮参数:网址参数 String
 
响应示例
{
  "status": "0",
  "reason": "success",
  "data": [
    {
      "appId": "xJdRmKR3ff",
      "templateId": "e66a5e3780d54b02adf1c280c10e90dd",
      "templateName": "shenfenyanz0904001",
      "templateCategory": 0,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(CHN)",
            "nameEn": "Chinese (CHN)",
            "code": "zh_CN"
          },
          "body": {
            "type": 0,
            "text": "{{#}}是您的验证码。",
            "exampleParams": [
              ""
            ]
          },
          "footer": "这组验证码将在10分钟后过期",
          "buttons": [
            {
              "type": 3,
              "text": "复制",
              "otp_type": "COPY_CODE"
            }
          ],
          "status": "FAILED",
          "reason": " Network exception ,Read Timed Out :I/O error on POST request for "https://graph.facebook.com/v17.0/113252591875166/message_templates": Connection reset; nested exception is java.net.SocketException: Connection reset"
        }
      ]
    },
    {
      "appId": "xJdRmKR3ff",
      "templateId": "ed33d767ab344c719d76a8d0e0d143f8",
      "templateName": "test121",
      "templateCategory": 1,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(CHN)",
            "nameEn": "Chinese (CHN)",
            "code": "zh_CN"
          },
          "body": {
            "type": 0,
            "text": "大促销"
          },
          "footer": "活动",
          "status": "APPROVED",
          "reason": "APPROVED"
        }
      ]
    },
    {
      "appId": "xJdRmKR3ff",
      "templateId": "b48e78ed68174a8aad41943579740a41",
      "templateName": "xk_template",
      "templateCategory": 1,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(CHN)",
            "nameEn": "Chinese (CHN)",
            "code": "zh_CN"
          },
          "header": {
            "type": 0,
            "text": "深圳"
          },
          "body": {
            "type": 0,
            "text": "大楚兴"
          },
          "footer": "xk",
          "status": "APPROVED",
          "reason": "APPROVED"
        }
      ]
    },
    {
      "appId": "xJdRmKR3ff",
      "templateId": "ca3a62cba9cc418fad73e3d2091d65b5",
      "templateName": "kj_api_test_test_02",
      "templateCategory": 1,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(CHN)",
            "nameEn": "Chinese (CHN)",
            "code": "zh_CN"
          },
          "header": {
            "type": 0,
            "text": "智能otp正在{{#}}活动中",
            "example": [
              "打折"
            ]
          },
          "body": {
            "type": 0,
            "text": "公司新开业, {{#}}活动火热进行中....",
            "exampleParams": [
              "打折"
            ]
          },
          "footer": "颂量科技",
          "status": "APPROVED",
          "reason": "APPROVED"
        }
      ]
    },
    {
      "appId": "xJdRmKR3ff",
      "templateId": "536566a0a3cb4bd3aa164e8bbbf06d5f",
      "templateName": "testgg",
      "templateCategory": 1,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(CHN)",
            "nameEn": "Chinese (CHN)",
            "code": "zh_CN"
          },
          "header": {
            "type": 0,
            "text": "“欢迎光顾 Vinny’s Bakery,我们现已入驻 WhatsApp!”{{#}}",
            "example": [
              "78994"
            ]
          },
          "body": {
            "type": 0,
            "text": "“欢迎光顾 Vinny’s Bakery,我们现已入驻 WhatsApp!”{{#}}",
            "exampleParams": [
              "sgasgah"
            ]
          },
          "footer": "“欢迎光顾 Vinny’s Bakery,我们现已入驻 WhatsApp!”",
          "status": "APPROVED",
          "reason": "APPROVED"
        }
      ]
    },
    {
      "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"
        }
      ]
    },
    {
      "appId": "xJdRmKR3ff",
      "templateId": "c1e5832031244d5ab4c7cee78d8ab0e0",
      "templateName": "xk_testt",
      "templateCategory": 1,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(CHN)",
            "nameEn": "Chinese (CHN)",
            "code": "zh_CN"
          },
          "body": {
            "type": 0,
            "text": "新店开业"
          },
          "footer": "哈哈",
          "status": "APPROVED",
          "reason": "APPROVED"
        }
      ]
    },
    {
      "appId": "xJdRmKR3ff",
      "templateId": "2f07cf4487b34e1f8aa62dfc2cdabf8b",
      "templateName": "xk_test34",
      "templateCategory": 1,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(CHN)",
            "nameEn": "Chinese (CHN)",
            "code": "zh_CN"
          },
          "body": {
            "type": 0,
            "text": "打折促销"
          },
          "footer": "哈哈",
          "status": "APPROVED",
          "reason": "APPROVED"
        }
      ]
    },
    {
      "appId": "xJdRmKR3ff",
      "templateId": "9379c9eaa23a4fd8a9d4fbe5f7c8d3f6",
      "templateName": "testdel",
      "templateCategory": 0,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(台湾)",
            "nameEn": "Chinese (TAI)",
            "code": "zh_TW"
          },
          "body": {
            "type": 0,
            "text": "{{#}}是您的驗證碼。",
            "exampleParams": [
              ""
            ]
          },
          "footer": "這組驗證碼將於10分鐘後失效",
          "buttons": [
            {
              "type": 3,
              "text": "fhfhfhhhhh",
              "otp_type": "COPY_CODE"
            }
          ],
          "status": "APPROVED",
          "reason": "APPROVED"
        }
      ]
    },
    {
      "appId": "xJdRmKR3ff",
      "templateId": "1e7c5d7575ba423392dc86047584ac15",
      "templateName": "kj_api_test_test",
      "templateCategory": 1,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(CHN)",
            "nameEn": "Chinese (CHN)",
            "code": "zh_CN"
          },
          "header": {
            "type": 0,
            "text": "智能otp正在{{#}}活动中",
            "example": [
              "打折"
            ]
          },
          "body": {
            "type": 0,
            "text": "公司新开业, {{#}}活动火热进行中....",
            "exampleParams": [
              "打折"
            ]
          },
          "footer": "颂量科技",
          "status": "APPROVED",
          "reason": "APPROVED"
        }
      ]
    },
    {
      "appId": "xJdRmKR3ff",
      "templateId": "75f10e79d1c54fd88cb68eeef040bff5",
      "templateName": "tg_template",
      "templateCategory": 1,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(CHN)",
            "nameEn": "Chinese (CHN)",
            "code": "zh_CN"
          },
          "header": {
            "type": 0,
            "text": "智能otp正在{{#}}活动中",
            "example": [
              "打折"
            ]
          },
          "body": {
            "type": 0,
            "text": "公司新开业, {{#}}活动火热进行中....",
            "exampleParams": [
              "打折"
            ]
          },
          "footer": "颂量科技",
          "status": "PENDING_DELETION",
          "reason": "PENDING_DELETION"
        }
      ]
    },
    {
      "appId": "xJdRmKR3ff",
      "templateId": "4e7ca085f8884f2da29a8cb85b8f5046",
      "templateName": "shenfenyanz",
      "templateCategory": 0,
      "templateLanList": [
        {
          "language": {
            "nameCn": "中文(CHN)",
            "nameEn": "Chinese (CHN)",
            "code": "zh_CN"
          },
          "body": {
            "type": 0,
            "text": "{{#}}是您的验证码。为安全起见,请不要分享这组验证码。",
            "exampleParams": [
              ""
            ]
          },
          "buttons": [
            {
              "type": 3,
              "text": "复制按钮",
              "otp_type": "COPY_CODE"
            }
          ],
          "status": "APPROVED",
          "reason": "APPROVED"
        }
      ]
    },
    {
        "templateId": "6471535898c24c51b65f4803a0d124a0",
        "templateName": "carsouel_template_01",
        "templateCategory": 1,
        "templateLanList": [
            {
                "language": {
                    "nameCn": "英语",
                    "nameEn": "English",
                    "code": "en"
                },
                "body": {
                    "type": 0,
                    "text": "main公司新开业, 活动火热进行中...."
                },
                "status": "APPROVED",
                "reason": "APPROVED",
                "headerType": "1",
                "carouselButtonsType": "1,4",
                "cards": [
                    {
                        "body": {
                            "type": 0,
                            "text": "cardbody公司新开业, 活动火热进行中...."
                        },
                        "header": {
                            "type": 1,
                            "fileId": "4::dmlkZW8vbXA0:ARaGs_UbTfracqe41jMJHGXQhnIDsu384_y2_hEcu9FUWINwpe0AixmsSAutsgdxEjnyPXPJh3av3Q9YdY5rR207iVWSbhZ1OKmD2RKUxEAhhQ:e:1773368540:1428167498027062:61550539014157:ARZPPgAWHJP2UKTcbJ4"
                        },
                        "buttons": [
                            {
                                "type": 1,
                                "text": "网站1",
                                "url": "https://www.google.com/"
                            },
                            {
                                "type": 4,
                                "text": "拨打电话-1",
                                "phoneNumber": "35866842",
                                "areaCode": "86"
                            }
                        ]
                    },
                    {
                        "body": {
                            "type": 0,
                            "text": "cardbody公司新开业, 活动火热进行中...."
                        },
                        "header": {
                            "type": 1,
                            "fileId": "4::dmlkZW8vbXA0:ARaGs_UbTfracqe41jMJHGXQhnIDsu384_y2_hEcu9FUWINwpe0AixmsSAutsgdxEjnyPXPJh3av3Q9YdY5rR207iVWSbhZ1OKmD2RKUxEAhhQ:e:1773368540:1428167498027062:61550539014157:ARZPPgAWHJP2UKTcbJ4"
                        },
                        "buttons": [
                            {
                                "type": 1,
                                "text": "网站-2",
                                "url": "https://www.google.com/"
                            },
                            {
                                "type": 4,
                                "text": "拨打电话-2",
                                "phoneNumber": "35266541",
                                "areaCode": "86"
                            }
                        ]
                    }
                ]
            }
        ],
        "markingChildType": 1
    }
  ]
} 
 
响应状态码
status 状态说明
0 成功
-1 身份验证错误
-2 模板状态不正确
-4 时间戳过期
-5 系统异常
-6 IP受限
-7 参数校验异常
-8 参数校验异常
-10 应用不存在
-11 应用名称已存在
-12 网络异常,请稍后重试
-14 账号未认证
 

language

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"
                }
            ]
        }
    ]
}                    
                

Telegram

微信扫码

立即咨询

客户服务热线

400-999-8488