修改角色資訊
更新時間:2024-07-22 15:17:01
舊版介面位址修改角色資訊(舊版)
介面描述
1、修改助教或嘉宾的信息
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
介面URL
http://api.polyv.net/live/v4/channel/account/update
請求方式
POST
介面限制
1、介面同時支援HTTP、HTTPS,建議使用HTTPS以確保介面安全,介面呼叫有頻率限制,詳細請查看
2、不能同時設定監播和翻頁以及線上列表權限
請求參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| appId | true | String | 帳號appId【詳見取得金鑰】 |
| timestamp | true | Long | 目前13位毫秒級時間戳記,3分鐘內有效 |
| sign | true | String | 簽名,為32位大寫的MD5值,產生簽名的appSecret金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有API都必須透過客戶自己伺服器中轉呼叫POLYV伺服器取得回應資料【詳見簽名產生規則】 |
| channelId | true | String | 頻道ID |
請求體參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| account | true | String | 助教/嘉賓帳號 |
| actor | false | String | 頭銜,助教預設為助教,長度1~10位 |
| nickName | false | String | 暱稱,預設隨機產生暱稱,長度1~15位 |
| avatar | false | String | 頭像,預設初始頭像 |
| passwd | false | String | 角色密碼,長度6~16位 |
| purviewList | false | Array | 權限【詳見purviewList欄位說明】 |
purviewList參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| code | true | String | 權限 chatListEnabled:線上列表(僅支援助教) pageTurnEnabled:翻頁(僅支援助教,且僅能設定一個助教有翻頁權限) monitorEnabled:監播(僅支援助教,且僅能設定一個助教有監播權限) chatAuditEnabled:聊天審核(僅支援助教) chatInteractionEnabled:互動發言(僅支援助教) chatWhenBannedEnabled:禁言時可發言(僅支援嘉賓) |
| enabled | true | String | 開關 Y:開啟 N:關閉 |
範例
http://api.polyv.net/live/v4/channel/account/update?appId=frlr1zazn3&sign=417802BACAD3375E72CA1A53848E0A53&channelId=2824409×tamp=1648779734640
請求體json參數:
{
"account": "0062824409",
"nickName": "测试修改昵称",
"purviewList": [
{
"code": "chatListEnabled",
"enabled": "Y"
},
{
"code": "pageTurnEnabled",
"enabled": "Y"
},
{
"code": "monitorEnabled",
"enabled": "N"
}]
}
回應參數描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| code | Integer | 狀態碼,與 http 狀態碼相同,用於確定基本的回應狀態 |
| status | String | 回應結果,由業務決定,成功回傳success,失敗回傳error |
| success | Boolean | 是否成功回應 |
| requestId | String | 請求ID,每次請求產生的唯一的 UUID,僅可用於排查、除錯,不應該和業務掛鉤 |
| error | Object | 狀態碼非200時的錯誤資訊【詳見Error欄位描述】 |
| data | Object | 【詳見data欄位說明】 |
Error參數描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| code | Integer | 錯誤代碼,用於確定具體的錯誤原因 |
| desc | String | 錯誤描述,與 error.code 對應 |
data參數描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| account | String | 助教/嘉賓帳號 |
| userId | String | 使用者ID |
| channelId | Integer | 頻道號 |
| passwd | String | 角色密碼 |
| nickname | String | 角色名稱 |
| stream | String | 角色流名,單獨使用無效 |
| status | String | 角色狀態 Y:開啟 N:關閉 |
| createdTime | Long | 建立角色時間,13位毫秒級時間戳記 |
| lastModified | Long | 角色最後修改時間,13位毫秒級時間戳記 |
| sort | Integer | 頻道角色序號 |
| avatar | String | 角色頭像 |
| actor | String | 角色頭銜 |
| role | String | 角色 Assistant:助教 Guest:嘉賓 |
| monitorEnabled | String | 監播權限 Y:開啟 N:關閉 |
| pageTurnEnabled | String | 翻頁權限 Y:開啟 N:關閉 |
| chatListEnabled | String | 線上列表權限 Y:開啟 N:關閉 |
| chatAuditEnabled | String | 聊天審核權限 Y:開啟 N:關閉 |
Java請求範例
快速接入基礎程式碼請下載相關依賴原始碼, 點擊下載原始碼 ,下載後加入到自己的原始碼工程中即可。測試案例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下載檔案中。
強烈建議您使用直播Java SDK完成API的功能對接,直播Java SDK 對API呼叫邏輯、例外處理、資料簽名、HTTP請求執行緒池進行了統一封裝和最佳化。
private static final Logger log = LoggerFactory.getLogger(ChannelOperateTest.class);
/**
* 更新角色信息
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testUpdateChannelAccount() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/channel/account/update";
String channelId = "2824409";
String account = "0062824409";
String nickName = "测试修改昵称";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", channelId);
List<Map<String, String>> purviewList = new ArrayList<>();
Map<String, String> purviewMap1 = new HashMap<>();
purviewMap1.put("code", "chatListEnabled");
purviewMap1.put("enabled", "Y");
purviewList.add(purviewMap1);
Map<String, String> purviewMap2 = new HashMap<>();
purviewMap2.put("code", "pageTurnEnabled");
purviewMap2.put("enabled", "Y");
purviewList.add(purviewMap2);
Map<String, String> purviewMap3 = new HashMap<>();
purviewMap3.put("code", "monitorEnabled");
purviewMap3.put("enabled", "N");
purviewList.add(purviewMap3);
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("account", account);
jsonMap.put("nickName", nickName);
jsonMap.put("purviewList", purviewList);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap), null);
log.info("测试更新角色信息成功:{}", response);
//do somethings
}
回應範例
系統全域錯誤說明詳見全域錯誤說明
成功範例
{
"code": 200,
"status": "success",
"requestId": "86d11d4aa00b49f5993ac0891e670470.59.16487797376158117",
"data":
{
"account": "0062824409",
"userId": "1b448be323",
"channelId": 2824409,
"passwd": "test123456",
"nickname": "测试修改昵称",
"stream": "l1fs56ih",
"status": "Y",
"createdTime": 1648778492000,
"lastModified": 1648779737622,
"sort": 6,
"avatar": "//liveimages.videocc.net/uploaded/images/2022/04/g8fydrvq5l.png",
"actor": "助教sadboy",
"pageTurnEnabled": "Y",
"notifyEnabled": "Y",
"checkinEnabled": "Y",
"voteEnabled": "Y",
"lotteryEnabled": "Y",
"chatListEnabled": "Y",
"chatAuditEnabled": "N",
"monitorEnabled": "N",
"roundTourEnabled": "N",
"watchLockEnabled": "N",
"role": "Assistant"
},
"success": true
}
異常範例
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
