# 删除频道聊天记录接口

### 接口URL

```
http://api.polyv.net/live/v2/chat/{channelId}/cleanChat
```

### 接口说明

```
1、接口用于删除频道所有聊天记录
2、接口URL中的{channelId}为 频道ID
3、接口支持https
```

### 支持格式

```
JSON
```

### 请求方式

```
POST
```

### 请求数限制

```
TRUE
```

### 请求参数

| 参数名       | 必选 | 类型     | 说明                                                                                                                                                                                                        |
| --------- | -- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| appId     | 是  | string | 从API设置中获取，在直播系统登记的appId                                                                                                                                                                                   |
| timestamp | 是  | string | 当前13位毫秒级时间戳，3分钟内有效                                                                                                                                                                                        |
| sign      | 是  | String | 签名，为32位大写的MD5值,`生成签名的appSecret密钥作为通信数据安全的关键信息，严禁保存在客户端直接使用，所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据`【详见[签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/live/api/buildSign/README.md)】 |

### 响应成功JSON示例：

```json
{
    "code": 200, 
    "status": "success", 
    "message": "", 
    "data": true
}
```

### 响应失败JSON示例：

未输入appId

```json
{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}
```

appId不正确

```json
{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}
```

时间戳错误

```json
{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}
```

签名错误

```json
{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
```

服务器错误

```json
{
    "code": 500, 
    "status": "fail", 
    "message": "api error.", 
    "data": ""
}
```

### 字段说明

| 参数名     | 说明                                     |
| ------- | -------------------------------------- |
| code    | 请求结果代码，成功为200 错误为400，签名错误为403，接口错误为500 |
| status  | 请求结果，成功时为"success"错误时为"error"          |
| message | 错误信息，请求成功时为空串，错误时错误信息                  |
| data    | 请求成功为true，错误为空串                        |

### php请求示例

```php
<?php
//引用config.php
include 'config.php';

$channelId="123713";

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp
);

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法


$url="http://api.polyv.net/live/v2/chat/".$channelId."/cleanChat";

function post($url, $post_data = '', $timeout = 5){
   $ch = curl_init();
   curl_setopt ($ch, CURLOPT_URL, $url);
   curl_setopt ($ch, CURLOPT_POST, 1);
   if($post_data != ''){
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
   }

   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
   curl_setopt($ch, CURLOPT_HEADER, false);
   $file_contents = curl_exec($ch);
   curl_close($ch);
   return $file_contents;
}

$params["sign"] = $sign;
echo post($url, $params);
?>
```

### 签名规则(config.php文件代码查看)
