Get Access Token for Watch Page Test Mode
Updated: 2023-11-14 17:02:20
API Description
1、接口用于获取观看页测试模式的访问令牌
2、接口支持https协议
API URL
https://api.polyv.net/live/v3/channel/watch/get-test-mode-token
Request Method
POST
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls are subject to rate limits. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See Get Secret Key |
| 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 never be used directly on the client side. All APIs must be called through your own server to relay requests to the POLYV server for response data. See Signature Generation Rules |
| channelId | true | String | Channel ID |
| expireTime | false | Integer | Token validity duration in seconds. Value range: 0 < expireSeconds <= 30 * 24 * 3600. Default is 4 * 3600 seconds |
Example
Request URL: https://api.polyv.net/live/v3/channel/watch/get-test-mode-token
Request Method: POST
Content-Type: application/x-www-form-urlencoded
Form Data: appId=<yourAppId>×tamp=1623308604852&sign=099846EF3DD92402DF9C60804556CE37&channelId=1762528
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. When code is 400 or 500, provides additional error reason |
| data | Object | Token information on successful request |
Java Request Example
For quick integration of basic code, download the relevant dependency source code. Click to download source code. After downloading, add it to your own source 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 pools.
private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 获取频道API的访问令牌
* @throws Exception
*/
@Test
public void testGetChannelApiToken() throws Exception {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "https://api.polyv.net/live/v3/channel/watch/get-test-mode-token";
String channelId = "1762528";
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));
String response = HttpUtil.postFormBody(url, requestMap);
log.info("获取观看页测试模式的访问令牌,返回值:{}",response);
}
Response Example
For system-wide global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"message": "",
"data": "65027cb0765c4d07afad13ba60467af2"
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
API Call Rate Limit
{
"code": 400,
"status": "error",
"message": "qps exceeds number of calls, limit: %s",
"data": ""
}
expireTime Value Constraint
{
"code": 400,
"status": "error",
"message": "过期时间太长",
"data": ""
}
