Delete Message Template
https://api.itniotech.com/wa/template/del
Parameters | Description | Required | Type |
---|---|---|---|
appId | Application id | Yes | String |
templateId | Template id | Yes | String |
Request URL:
https://api.itniotech.com/wa/template/del
Request Method:
POST
Request Headers:
Content-Type: application/json;charset=UTF-8
Sign: 05d7a50893e22a5c4bb3216ae3396c7c
Timestamp: 1630468800
Api-Key: bDqJFiq9
Request Body:
{
"appId":"xJdRffKR3",
"templateId":"9379c9eaa23a4fd8a9d4fbe5f7c8d3f6"
}
Parameters | Description | Type |
---|---|---|
status | Status code, 0 is successful, other failures refer to the interface response code | String |
reason | Reason | String |
status | Description |
---|---|
0 | success |
-1 | Authentication error |
-2 | Incorrect template status |
-4 | Timestamp expires |
-5 | System exception ! |
-6 | Restricted IP access |
-7 | json parse exception, plase check you param's type and json format |
-8 | Abnormal parameter verification |
-10 | Application does not exist |
-11 | The application name already exists |
-12 | Network exception or parameter error |
-14 | Account not authenticated |
-38 | It is failed to delete the template,current template was not found. |
-39 | It is failed to delete the template. |
-74 | The languageCode format err |
-76 | Please enter the correct type |
-83 | Please enter the correct format params |
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 delTemplate() {
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/del");
HttpRequest request = HttpRequest.post(url);
// currentTime
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/del";
$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"
}