Modify Channel Icon
Interface Description
1、设置频道图标
2、接口URL中的{channelId}为频道号
3、建议直接上传分辨率为128X128的图片
4、(timestamp, appId)参与sign签名,并和sign一起通过post表单传递,文件通过二进制流提交到服务器端。
5、接口支持https协议
Interface URL
http://api.polyv.net/live/v2/channelSetting/{channelId}/setCoverImg
Request Method
POST
Interface Constraints
The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls are subject to frequency limits. See details
The uploaded image must be a local image no larger than 2MB (only JPG, JPEG, PNG formats are allowed).
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See details on obtaining credentials |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be saved or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules |
| imgfile | true | File | Image file, must be JPG, JPEG, or PNG format, no larger than 2MB |
Example
http://api.polyv.net/live/v2/channelSetting/1965681/setCoverImg
Form parameters:
appId=frlr1zazn3&sign=ADF695A18E021A16E0738D0D4CB13C7B×tamp=1621840589933
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code, 200 indicates success, non-200 indicates failure See global error description |
| status | String | Response status text |
| message | String | Response description, provides additional error details when code is 400 or 500 |
| data | String | On success, returns the URL of the uploaded image; on failure, returns empty |
Java Request Example
For quick integration of basic code, download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source code project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded file.
It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pooling.
private static final Logger log = LoggerFactory.getLogger(WebInfoTest.class);
/**
* 修改频道图标
* @throws IOException
*/
@Test
public void testUpdateChannelLogo() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId=super.appId;
String appSecret=super.appSecret;
String userId = super.userId;
String timestamp=String.valueOf(System.currentTimeMillis());
//业务参数
String url = String.format("http://api.polyv.net/live/v2/channelSetting/%s/setCoverImg","1965681");
String path = getClass().getResource("/file/").getPath() + "dog.jpeg";
File file = new File(path);
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
Map<String,File> fileMap = new HashMap<>();
fileMap.put("imgfile",file);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.postFile(url,requestMap,fileMap,"utf-8");
log.info("测试修改频道图标:{}",response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code":200,
"status":"success",
"message":"",
"data":"//liveimages.videocc.net/uploaded/images/2021/03/fwtb3ip6c0.jpeg"
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
