服务端API文档

接口概述

一、服务地址

全时云直播域名:参照 https://developer.quanshi.com/cn/api/560 说明

二、通信协议

所有接口均通过HTTPS进行通信,提供高安全性的通信通道。

三、请求方法

所有接口都只支持POST请求。

四、字符编码

所有接口均使用UTF-8编码

五、公共参数

所有接口均需要放置以下公共参数在请求头中,用于标识用户和接口鉴权

参数 类型 必须 说明
AppId String 开发者平台分配的appId
Nonce String 随机数(随机数,最大长度128个字符)
CurTime String 当前UTC时间戳,从1970年1月1日0点0分0秒开始到现在的毫秒数
CheckSum String 服务器认证需要,16进制字符小写SHA1(AppSecret+Nonce+CurTime)

六、接口鉴权

重要提示: 本文档中提供的所有接口均面向服务器端调用,用于计算的AppSecret开发者应妥善保管

计算checkSum的java代码举例如下:

import java.security.MessageDigest; 

publicclassCheckSumBuilder {
    private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; 

    publicstaticStringgetCheckSum(String appSecret, String nonce, String curTime){ 
        return encode("sha1", appSecret + nonce + curTime); 
    } 

    privatestaticStringencode(String algorithm, String value){ 
        if (value == null) { 
            return null; 
        } 
        try { 
            MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
            messageDigest.update(value.getBytes()); 
            return getFormattedText(messageDigest.digest()); 
        } catch (Exception e) { 
            thrownew RuntimeException(e); 
        } 
    } 

    privatestaticStringgetFormattedText(byte[] bytes){ 
        int len = bytes.length; 
        StringBuilder buf = new StringBuilder(len * 2); 
        for (int j = 0; j < len; j++) { 
            buf.append(HEX_DIGITS[(bytes[j] >>4) &0x0f]); 
            buf.append(HEX_DIGITS[bytes[j] &0x0f]); 
        } 
        return buf.toString(); 
    } 
}

七、返回说明

所有接口返回类型为JSON。返回结构如下:

参数 类型 说明
timeStamp Long 返回时间(时间戳,单位毫秒)
requestId String 请求ID(在接口异常时, 需提供请求ID)
code Int 返回的状态码
msg String 当返回结果的状态码不为200时,包含的错误信息
data Json 返回值