更新白名單
更新時間:2022-10-12 15:25:43
介面描述
1、更新白名单
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
4、接口更新为局部更新,即不传的字段维持不变
介面URL
https://api.polyv.net/meet/v1/channel/auth-whitelist/update
請求方式
POST
介面限制
1、介面呼叫有頻率限制,詳細請查看
請求參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| appId | true | String | 帳號appId【詳見取得密鑰】 |
| timestamp | true | Long | 當前13位毫秒級時間戳,3分鐘內有效 |
| sign | true | String | 簽名,為32位大寫的MD5值【詳見簽名生成規則】 |
| channelId | true | Integer | 頻道號 |
請求體參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| oldCode | true | String | 需要更新的原白名單記錄,長度不超過64位 |
| code | true | String | 新的白名單記錄,長度不超過64位 |
| name | false | String | 新的暱稱,長度不超過64位(不傳則不修改) |
| groupNo | false | Integer | 新的分組序號,1~50之間(不傳則不修改) |
| groupRole | false | String | 新的組內身份(不傳則不修改) leader:組長 member:組員 |
範例
https://api.polyv.net/meet/v1/channel/auth-whitelist/update?appId=fyirmfdak4×tamp=1657786379352&sign=CEA301164F9BA5076F156C1EB60F22F8&channelId=3220878
請求體參數
{
"oldCode" : "oldCode",
"code" : "code",
"name" : "name",
"groupNo" : 1,
"groupRole" :"member"
}
響應參數描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| code | Integer | 狀態碼,與 http 狀態碼相同,用於確定基本的響應狀態 |
| status | String | 響應結果,由業務決定,成功返回success,失敗返回error |
| success | Boolean | 是否成功響應 |
| requestId | String | 請求ID,每次請求生成的唯一的 UUID,僅可用於排查、除錯,不應該和業務掛鉤 |
| error | Object | 狀態碼非200時的錯誤資訊【詳見Error欄位描述】 |
| data | String | 成功時為true,錯誤時為空 |
Error參數描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| code | Integer | 錯誤代碼,用於確定具體的錯誤原因 |
| desc | String | 錯誤描述,與 error.code 對應 |
Java請求範例
快速接入基礎代碼請下載相關依賴原始碼, 點擊下載原始碼 ,下載後加入到自己的原始碼工程中即可。測試用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下載檔案中。
強烈建議您使用直播Java SDK完成API的功能對接,直播Java SDK 對API呼叫邏輯、異常處理、資料簽名、HTTP請求執行緒池進行了統一封裝和最佳化。
private static final Logger log = LoggerFactory.getLogger(WhitelistUpdate.class);
/**
* 更新白名单
* @throws IOException
*/
@Test
public void testWhitelistUpdate() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId=super.appId;
String appSecret=super.appSecret;
String userId = super.userId;
String timestamp=String.valueOf(System.currentTimeMillis());
//业务参数
String url = "https://api.polyv.net/meet/v1/channel/auth-whitelist/update";
String channelId = "2191532";
String body = "{\n" +
" \"oldCode\" : \"oldCode\",\n" +
" \"code\" : \"code\",\n" +
" \"name\" : \"name\",\n" +
" \"groupNo\" : 1,\n" +
" \"groupRole\" :\"member\"\n" +
"}";
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("channelId",channelId);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, body, null);
log.info("测试更新白名单接口返回值:{}",response);
//do somethings
}
響應範例
系統全域錯誤說明詳見全域錯誤說明
成功範例
{
"code": 200,
"status": "success",
"message": "",
"data": true
}
異常範例
{
"code": 400,
"status": "error",
"error": {
"code": 10003,
"desc": "时间戳过期"
},
"success": false
}
{
"code": 403,
"status": "error",
"error": {
"code": 10002,
"desc": "签名错误"
},
"success": false
}
{
"code": 400,
"status": "error",
"requestId": "a7d7886f4a8c4938819b48c1b969ac04.66.16655445009590005",
"error": {
"code": 10001,
"desc": "原始会员码不能为空"
},
"data": null,
"success": false
}
{
"code": 400,
"status": "error",
"requestId": "a7d7886f4a8c4938819b48c1b969ac04.63.16655444886950005",
"error": {
"code": 10001,
"desc": "会员码不能为空"
},
"data": null,
"success": false
}
{
"code": 400,
"status": "error",
"requestId": "a7d7886f4a8c4938819b48c1b969ac04.57.16655448630610035",
"error": {
"code": 10001,
"desc": "会员码长度需要介于1和64之间"
},
"data": null,
"success": false
}
{
"code": 400,
"status": "error",
"requestId": "a7d7886f4a8c4938819b48c1b969ac04.59.16655445255610009",
"error": {
"code": 10001,
"desc": "昵称长度需要介于1和64之间"
},
"data": null,
"success": false
}
{
"code": 400,
"status": "error",
"requestId": "a7d7886f4a8c4938819b48c1b969ac04.58.16655455179100093",
"error": {
"code": 10001,
"desc": "组内身份不正确"
},
"data": null,
"success": false
}
{
"code": 400,
"status": "error",
"requestId": "a7d7886f4a8c4938819b48c1b969ac04.61.16655444651140003",
"error": {
"code": 50202,
"desc": "白名单不存在"
},
"data": null,
"success": false
}
{
"code": 400,
"status": "error",
"requestId": "a7d7886f4a8c4938819b48c1b969ac04.60.16655454803730087",
"error": {
"code": 50203,
"desc": "会员码已存在"
},
"data": null,
"success": false
}
{
"code": 400,
"status": "error",
"requestId": "a7d7886f4a8c4938819b48c1b969ac04.63.16655455046100091",
"error": {
"code": 50204,
"desc": "更新白名单失败,组内已有组长"
},
"data": null,
"success": false
}
