打赏-发送打赏消息

接口URL

http://api.polyv.net/live/v3/channel/chat/send-reward-msg

接口说明

  1. 用于发送打赏消息
  2. 请求成功后,服务器会向聊天室的用户广播打赏消息,详见直播聊天室API接口
  3. 接口支持https

支持格式

JSON

请求方式

POST

请求参数

参数名 必选 类型 说明
channelId int 频道ID
appId string 账号的应用ID,在后台的“开发设置”获取
timestamp long 13位毫秒级时间戳
sign string 签名,为32位大写的MD5值
nickname string 打赏者昵称
avatar string 打赏者头像
viewerId string 打赏者ID
donateType string 打赏类型,取值:cash 现金打赏,good 道具打赏
content string 打赏内容:礼物打赏为礼物名称,现金打赏为金额
goodImage string 礼物打赏时为礼物图片,现金打赏时为空
sessionId string 直播场次ID

响应成功JSON示例:

{
    "code": 200, 
    "status": "success", 
    "message": "", 
    "data": 0
}

响应失败JSON示例:

未输入appId

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

appId不正确

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

时间戳错误

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

签名错误

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

频道号格式错误

{
  "code": 400,
  "status": "error",
  "message": "param is not digit: 输入的错误频道号",
  "data": ""
}

道具打赏时未提交道具图片

{
  "code": 400,
  "status": "error",
  "message": "param should not be empty:goodImage",
  "data": ""
}

发送失败

{
    "code": 400,
    "status": "error",
    "message": "send message failure",
    "data": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为403,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 暂无作用

请求示例

<?php
//引用config.php
include 'config.php';

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => "108888",
  'nickname' => "wenen",
  'avatar' => "https://livestatic.videocc.net/uploaded/images/webapp/avatar/default-teacher.png",
  'viewerId' => "123",
  'donateType' => "good",
  'content' => "黄钻",
  'goodImage' => "http://livestatic.videocc.net/uploaded/images/webapp/channel/donate/06-star.png"
);

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法


$url="http://api.polyv.net/live/v3/channel/chat/send-reward-msg";

function post($url, $post_data = '', $timeout = 5){
   $ch = curl_init();
   curl_setopt ($ch, CURLOPT_URL, $url);
   curl_setopt ($ch, CURLOPT_POST, 1);
   if($post_data != ''){
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
   }

   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
   curl_setopt($ch, CURLOPT_HEADER, false);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
   $file_contents = curl_exec($ch);
   curl_close($ch);
   return $file_contents;
}

$params["sign"] = $sign;
echo post($url,http_build_query($params));
?>

签名规则(config.php文件代码查看)

http://dev.polyv.net/2018/liveproduct/l-api/rule/sign/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...

抽奖-提交中奖者信息

接口URL

http://api.polyv.net/live/v3/channel/chat/add-receive-info

接口说明

1、用于提交中奖者填写的信息
2、只能成功保存一次观众中奖信息
3、中奖信息需在7天内提交保存,否则会失效
4、接口支持https

支持格式

JSON

请求方式

POST

请求参数

参数名 必选 类型 说明
channelId string 频道ID
appId string 账号的应用ID,在后台的“开发设置”获取
timestamp long 13位毫秒级时间戳
sign string 签名,为32位大写的MD5值
lotteryId string 抽奖场次ID
winnerCode string 中奖码
viewerId string 中奖者ID
name string 中奖者姓名
telephone string 中奖者手机号码

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "保存成功",
    "data": ""
}

响应失败JSON示例:

手机号码格式错误

{
    "code": 400,
    "status": "fail",
    "message": "手机号码格式错误",
    "data": ""
}

重复提交(已经成功提交过中奖信息后则不能再次请求)

{
    "code": 400,
    "status": "fail",
    "message": "请勿重复提交",
    "data": ""
}

中奖码不存在

{
    "code": 400,
    "status": "fail",
    "message": "中奖码不存在",
    "data": ""
}

抽奖场次ID错误

{
    "code": 400,
    "status": "fail",
    "message": "illegal lottery id: 错误的ID",
    "data": ""
}

有参数未提交

{
  "code": 400,
  "status": "error",
  "message": "param should not be empty:未提交的参数名",
  "data": ""
}

字段说明

参数名 说明
code 请求状态响应码
status 请求状态
message 错误信息
data 暂无作用

请求示例

<?php
//引用config.php
include 'config.php';

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => "108888",
  'lotteryId' => "f76did5ldj",
  'viewerId' => "viewerId1231",
  'winnerCode' => "12121212123",
  'name' => "wenwenwen",
  'telephone' => "15625123456"
);

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法


$url="http://api.polyv.net/live/v3/channel/chat/add-receive-info";

function post($url, $post_data = '', $timeout = 5){
   $ch = curl_init();
   curl_setopt ($ch, CURLOPT_URL, $url);
   curl_setopt ($ch, CURLOPT_POST, 1);
   if($post_data != ''){
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
   }

   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
   curl_setopt($ch, CURLOPT_HEADER, false);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
   $file_contents = curl_exec($ch);
   curl_close($ch);
   return $file_contents;
}

$params["sign"] = $sign;
echo post($url,http_build_query($params));
?>

签名规则(config.php文件代码查看)

http://dev.polyv.net/2018/liveproduct/l-api/rule/sign/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...

问卷设置

接口URL

https://api.polyv.net/live/v3/channel/questionnaire/add-edit-questionnaire

接口说明

1、接口用于编辑或添加问卷信息,为全量增加或修改
2、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 当前13位毫秒级时间戳,3分钟内有效
sign string 签名,为32位大写的MD5值
channelId string 频道号
questionnaireId string 问卷id,修改问卷时需要
questionnaireTitle string 问卷标题
questions array 题目数组
questions[].questionId string 题目id,修改问卷时需要传
questions[].name string 题目
questions[].type string 题目类型,R为单选,C为多选,Q为问答
questions[].scoreEnabled string 题目是否需要评分,Y为需要,N为不需要
questions[].answer string 需要评分的选择题才有答案,填入对应选项序号,如:A或AB
questions[].required string 题目是否为必答,Y为必答,N为非必答
questions[].options array 题目为单选题或多选题为必填,选项数组下标0-9对应答案A-J
questions[].options[] string 选项描述

注:这里的channelId,appId,timestamp,sign必须通过url传参,json数据通过请求体传参,如:

https://api.polyv.net/live/v3/channel/questionnaire/add-edit-questionnaire?channelId={{channelId}}&appId={{appId}}&timestamp={{timestamp}}&sign={{sign}}

请求体json拼接

{
  "questionnaireId": "f8v53d83qe",
  "questionnaireTitle": "问卷标题", 
  "questions": [
    {
      "questionId": "feqfr13ftz", 
      "name": "题目名称", 
      "type": "R", 
      "answer": "A", 
      "scoreEnabled": "Y", 
      "score": 10, 
      "required": "Y", 
      "options": [
        "选项1", 
        "选项2", 
        "选项3"
      ]
    }
  ]
}

响应成功JSON示例:

{
  "code": 200, 
  "status": "success", 
  "message": "", 
  "data": {
    "questionnaireId": "f8v3visks0", 
    "questionIds": [
      "3ff650e4d4"
    ]
  }
}

响应失败JSON示例:

未输入appId

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

appId不正确

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

时间戳错误

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

签名错误

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

频道号格式错误

{
  "code": 400, 
  "status": "error", 
  "message": "param is not digit: dsadasd", 
  "data": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 成功响应时为问卷和题目id
data.questionnaireId 问卷id
data.questionIds[] 题目的id数组

Java请求示例

import com.live.util.EncryptionUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Demo {

    private static RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(15000).setConnectTimeout(15000)
            .setConnectionRequestTimeout(15000).build();

    public static void main(String[] args) {

        String url = "https://api.polyv.net/live/v3/channel/questionnaire/add-edit-questionnaire";
        int channelId = 206204;
        String appId = "f018j7iirt";
        String key = "96651acd43e04cc8a94a1cfa60cec909";
        Map<String, String> map = new HashMap<>();
        long timestamp = System.currentTimeMillis();
        map.put("appId", appId);
        map.put("timestamp", String.valueOf(timestamp));
        map.put("channelId", String.valueOf(channelId));

        String sign = getSign(map, key);
        map.put("sign", sign);
        String body = "{\"questionnaireTitle\":\"问卷标题\",\"questions\":[{\"questionId\":null,\"name\":\"题目名称\"," +
                "\"type\":\"R\",\"answer\":\"A\",\"scoreEnabled\":\"Y\",\"score\":10,\"required\":\"Y\"," +
                "\"options\":[\"选项1\",\"选项2\",\"选项3\"]}],\"questionnaireId\":null}";
        String content = sendHttpPost(url, map, body);
        System.out.println(content);

    }

    /**
     * 发送 post请求
     * @param httpUrl 地址
     * @param maps 参数
     */
    public static String sendHttpPost(String httpUrl, Map<String, String> maps, String body) {
        StringBuilder url = new StringBuilder();
        url.append(httpUrl).append("?");
        for (Map.Entry<String, String> map : maps.entrySet()) {
            url.append(map.getKey()).append("=").append(map.getValue()).append("&");
        }
        String urlStr = url.toString().substring(0, url.length() - 1);
        // 创建httpPost
        HttpPost httpPost = new HttpPost(urlStr);
        try {
            StringEntity entity = new StringEntity(body, Charset.forName("UTF-8"));
            httpPost.setEntity(entity);
        } catch (Exception e) {
            // ...
        }
        return sendHttpPost(httpPost);
    }

    /**
     * 发送Post请求
     * @param httpPost
     * @return
     */
    private static String sendHttpPost(HttpPost httpPost) {
        CloseableHttpClient httpClient = null;
        CloseableHttpResponse response = null;
        HttpEntity entity;
        String responseContent = null;
        try {
            // 创建默认的httpClient实例.
            httpClient = HttpClients.createDefault();
            httpPost.setConfig(requestConfig);
            // 执行请求
            response = httpClient.execute(httpPost);
            entity = response.getEntity();
            responseContent = EntityUtils.toString(entity, "UTF-8");
        } catch (Exception e) {
            // ...
        } finally {
            try {
                // 关闭连接,释放资源
                if (response != null) {
                    response.close();
                }
                if (null != httpPost) {
                    httpPost.releaseConnection();
                }
                if (httpClient != null) {
                    httpClient.close();
                }
            } catch (IOException e) {
                // ...
            }
        }
        return responseContent;
    }

    /**
     * 根据map里的参数构建加密串
     * @param map
     * @param secretKey
     * @return
     */
    protected static String getSign(Map<String, String> map, String secretKey) {
        Map<String, String> params = paraFilter(map);
        // 处理参数,计算MD5哈希值
        String concatedStr = concatParams(params);
        String plain = secretKey + concatedStr + secretKey;
        String encrypted = EncryptionUtils.md5Hex(plain);

        // 32位大写MD5值
        return encrypted.toUpperCase();
    }

    /**
     * 对params根据key来排序并且以key1=value1&key2=value2的形式拼接起来
     * @param params
     * @return
     */
    private static String concatParams(Map<String, String> params) {
        List<String> keys = new ArrayList<>(params.keySet());
        Collections.sort(keys);

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < keys.size(); i++) {
            String key = keys.get(i);
            String value = params.get(key);

            sb.append(key).append(value);
        }

        return sb.toString();
    }

    /**
     * 除去数组中的空值和签名参数
     * @param sArray 签名参数组
     * @return 去掉空值与签名参数后的新签名参数组
     */
    private static Map<String, String> paraFilter(Map<String, String> sArray) {

        Map<String, String> result = new HashMap<>();

        if (sArray == null || sArray.size() <= 0) {
            return result;
        }

        for (String key : sArray.keySet()) {
            String value = sArray.get(key);
            if (value == null || value.equals("") || key.equalsIgnoreCase("sign")
                    || key.equalsIgnoreCase("sign_type")) {
                continue;
            }
            result.put(key, value);
        }

        return result;
    }

}

php请求示例

<?php
//引用config.php
include 'config.php';

$params = array(
    'appId' => $appId,
    'timestamp' => $timestamp,
    'channelId' => 206204
);

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$params['sign'] = $sign;

$url = "https://api.polyv.net/live/v3/channel/questionnaire/add-edit-questionnaire?".http_build_query($params);
$json = '{
  "questionnaireTitle": "问卷标题", 
  "questions": [
    {
      "questionId": null, 
      "name": "题目名称", 
      "type": "R", 
      "answer": "A", 
      "scoreEnabled": "Y", 
      "score": 10, 
      "required": "Y", 
      "options": [
        "选项1", 
        "选项2", 
        "选项3"
      ]
    }
  ], 
  "questionnaireId": null
}';

function post($url, $post_data = '', $timeout = 5){
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_POST, 1);
    if($post_data != ''){
       curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    }

    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($post_data)));
    $file_contents = curl_exec($ch);
    curl_close($ch);
    return $file_contents;
}

echo post($url,$json);
?>

签名规则(config.php文件代码查看)

http://dev.polyv.net/2018/liveproduct/l-api/rule/sign/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...

问卷结果查询API

接口URL

https://api.polyv.net/live/v3/channel/questionnaire/answer-records

接口说明

1、接口用于查询直播问卷的答题结果及统计
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 当前13位毫秒级时间戳,3分钟内有效
sign string 签名,为32位大写的MD5值
channelId int 频道号
startDate string 开始时间,格式:2018-12-10
endDate string 结束时间,格式:2018-12-10

响应成功JSON示例:

{
"code": 200,
"status": "success",
"message": "",
"data": [
{
"questionnaireId": "f7g2gtgtsd",
"questionnaireTitle": "ttt",
"questionStats": {
"questions": [
{
"questionId": "f7g2gtgtt9",
"score": 10,
"totalScore": 10,
"total": 2,
"correctCount": 1,
"d": 0,
"e": 0,
"f": 0,
"h": 0,
"i": 0,
"j": 0,
"c": 0,
"a": 1,
"b": 1,
"g": 0
},
{
"questionId": "f7g2gtgtyg",
"score": 10,
"totalScore": 10,
"total": 2,
"correctCount": 1,
"d": 0,
"e": 0,
"f": 0,
"h": 0,
"i": 0,
"j": 0,
"c": 0,
"a": 1,
"b": 1,
"g": 0
}
],
"total": 2
},
"users": [
{
"viewerId": "1544406042082",
"nickname": "广州观众/98347",
"totalScore": 20,
"answers": [
{
"questionId": "f7g2gtgtt9",
"questionName": "a",
"answer": "A",
"score": 10,
"type": "R"
},
{
"questionId": "f7g2gtgtyg",
"questionName": "b",
"answer": "A",
"score": 10,
"type": "R"
}
]
},
{
"viewerId": "oL0En04rCbHNSNdey_rFMAkLT-Ps",
"nickname": "ilyq69",
"totalScore": 0,
"answers": [
{
"questionId": "f7g2gtgtt9",
"questionName": "a",
"answer": "B",
"score": 0,
"type": "R"
},
{
"questionId": "f7g2gtgtyg",
"questionName": "b",
"answer": "B",
"score": 0,
"type": "R"
}
]
}
]
}
]
}

响应失败JSON示例:

未输入appId

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

appId不正确

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

时间戳错误

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

签名错误

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

频道号格式错误

{
  "code": 400, 
  "status": "error", 
  "message": "param is not digit: dsadasd", 
  "data": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为401,异常错误500(http状态码也跟code相同)
status 成功为success,失败为error
message 错误时为错误提示消息
data 成功时,返回用户答题结果及各个题目的统计信息,是个数组
questionnaireId 问卷ID,string
questionnaireTitle 问卷名称,string
questionStats 问卷下各个问题的答题统计
questionStats.total 题目的答题人数,int
questionStats.questions 题目的答题统计信息,数组[]
questionStats.questions[].questionId 题目ID,string
questionStats.questions[].questionName 题目名称,string
questionStats.questions[].score 题目分数,int
questionStats.questions[].totalScore 题目的总得分,int
questionStats.questions[].correctCount 题目的答对人数,int
questionStats.questions[].a-g 选择项a到g分别的答题人数,int
users 观看端提交答题的信息
users[].viewerId 提交问卷的用户ID,string
users[].nickname 提交问卷的用户昵称,string
users[].totalScore 提交问卷的用户的总得分,int
users[].answers[] 用户每道题目的答题情况,数组 []
users[].answers[].questionId 题目ID,string
users[].answers[].questionName 题目名称,string
users[].answers[].answer 提交的题目答案,string
users[].answers[].score 用户答题的得分,string
users[].answers[].type 题目的类型,string,R 单选题 ,C 多项题 ,Q 问答题

php请求示例

<?php
//引用config.php
include 'config.php';

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => 195770,
  'startDate' => '2018-12-08',
  'endDate' => '2018-12-10'  
);

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$params['sign'] = $sign;

$url = "http://api.polyv.net/live/v3/channel/questionnaire/answer-record?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
$res = curl_exec($curl);
curl_close($curl);

echo $res;
?>

签名规则(config.php文件代码查看)

http://dev.polyv.net/2018/liveproduct/l-api/rule/sign/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...

获取签到结果

接口URL

https://api.polyv.net/live/v3/channel/checkin/list

接口说明

1、接口用于分页查询频道号下某一天的签到记录
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号
page int 页码,默认为1
pageSize int 每一页的大小,默认为20
date string 查询的指定日期,格式为yyyy-MM-dd

响应成功JSON示例:

{
  "code": 200,
  "status": "success",
  "message": "",
  "data": {
    "pageNumber": 1,
    "totalPages": 1,
    "pageSize": 20,
    "contents": [
      {
        "id": 491,
        "indate": "2018-08-07",
        "userid": "1533622191653",
        "channelId": 100538,
        "time": 1533622526801,
        "timeFormat": "2018-08-07 14:15",
        "nickname": "广州观众/28838"
      },
      {
        "id": 492,
        "indate": "2018-08-07",
        "userid": "1533622191653",
        "channelId": 100538,
        "time": 1533623311065,
        "timeFormat": "2018-08-07 14:28",
        "nickname": "广州观众/28838"
      },
      {
        "id": 493,
        "indate": "2018-08-07",
        "userid": "1533622191653",
        "channelId": 100538,
        "time": 1533636856928,
        "timeFormat": "2018-08-07 18:14",
        "nickname": "广州观众/28838"
      },
      {
        "id": 494,
        "indate": "2018-08-07",
        "userid": "1533607482637",
        "channelId": 100538,
        "time": 1533636856932,
        "timeFormat": "2018-08-07 18:14",
        "nickname": "chromexr"
      },
      {
        "id": 495,
        "indate": "2018-08-07",
        "userid": "1533625048644",
        "channelId": 100538,
        "time": 1533636875744,
        "timeFormat": "2018-08-07 18:14",
        "nickname": "ffxiaoru"
      }
    ]
  }
}

响应失败JSON示例:

未输入appId

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

appId不正确

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

时间戳错误

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

签名错误

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

channelId为空

{
  "code": 400, 
  "status": "error", 
  "message": "param should not be empty: channelId", 
  "data": ""
}

channelId为非数字

{
  "code": 400, 
  "status": "error", 
  "message": "param is not number: channelId", 
  "data": ""
}

频道非法

{
  "code": 403, 
  "status": "error", 
  "message": "illegal channel id: 206240", 
  "data": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 签到记录的分页数据
pageNumber 页码
totalPages 总页数
pageSize 每一页大小
contents 签到记录数据数组
indate 查询的签到日期,yyyy-MM-dd格式
nickname 昵称
userid 用户id
channelId 频道号
time 签到的具体时间戳
timeFormat 签到的格式化详细日期,yyyy-MM-dd HH:mm 格式

php请求示例

<?php

//引用config.php
include 'config.php';

//接口URL上变量
$appId = "es2vsst178";
$channelId="223350";
$date="2018-08-08";
$pageSize="20";
$page="1";
//接口需要的参数(非sign)赋值
$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => $channelId,
  'page' => $page,
  'pageSize' => $pageSize,
  'date' => $date
);

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法

//接口请求url
$url = "https://api.polyv.net/live/v3/channel/checkin/list?appId=".$appId."&sign=".$sign."&timestamp=".$timestamp."&channelId=".$channelId."&page=".$page."&pageSize=".$pageSize."&date=".$date;

//输出接口请求结果
echo file_get_contents($url);

?>

签名规则(config.php文件代码查看)

http://dev.polyv.net/2018/liveproduct/l-api/rule/sign/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...

查询频道答题卡答题结果

接口URL

https://api.polyv.net/live/v3/channel/question/answer-records

接口说明

1、接口用于获取频道的答题卡答题结果列表
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号
startDate string 查询的开始时间
endDate string 查询的结束时间

ps:开始和结束时间为空的默认查最近7天的数据。

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "questionId": "f31lrsr9vx",
            "questionTitle": "测试1",
            "answer": "B",
            "total": 1,
            "correctCount": 0,
            "options": [
                {
                    "title": ",,",
                    "count": 1,
                    "percent": "100.00%"
                },
                {
                    "title": "..",
                    "count": 0,
                    "percent": "0.00%"
                }
            ],
            "records": [
                {
                    "viewerId": "1531987278863",
                    "nickname": "广州观众/79713",
                    "answer": "A",
                    "corrent": false
                }
            ]
        },
        {
            "questionId": "f31lr45sjl",
            "questionTitle": "测试1",
            "answer": "A",
            "total": 1,
            "correctCount": 1,
            "options": [
                {
                    "title": "nn",
                    "count": 1,
                    "percent": "100.00%"
                },
                {
                    "title": "m,m",
                    "count": 0,
                    "percent": "0.00%"
                }
            ],
            "records": [
                {
                    "viewerId": "1531987278863",
                    "nickname": "广州观众/79713",
                    "answer": "A",
                    "corrent": false
                }
            ]
        }
    ]
}

响应失败JSON示例:

未输入appId

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

appId不正确

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

时间戳错误

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

签名错误

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

channelId为空

{
  "code": 400, 
  "status": "error", 
  "message": "param should not be empty: channelId", 
  "data": ""
}

channelId为非数字

{
  "code": 400, 
  "status": "error", 
  "message": "param is not number: channelId", 
  "data": ""
}

频道非法

{
  "code": 403, 
  "status": "error", 
  "message": "illegal channel id: 206240", 
  "data": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 答题结果列表数据
questionId 答题ID
answer 题目的答案
total 答题人数
options 题目选项信息列表
title 选项标题
count 选择该选项的人数
percent 选择该选项的人数百分比
records 答题的用户列表
viewerId 答题的用户ID
nickname 答题的用户昵称
answer 答题的用户提交的答案
corrent 答题的用户提交的答案是否正确:false不正确,true正确

php请求示例

<?php
//引用config.php
include '/srv/http/config.php';

$channelId="206204";

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => $channelId,
  'startDate' => '2018-07-01',
  'endDate' => '2018-07-18'
);

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$params['sign'] = $sign;

$url = "https://api.polyv.net/live/v3/channel/question/answer-records?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
curl_close($curl);

echo $res;
?>

签名规则(config.php文件代码查看)

http://dev.polyv.net/2018/liveproduct/l-api/rule/sign/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...

点赞功能接口

接口URL

http://api.polyv.net/live/v2/channels/{channelId}/like

接口说明

1、用于实现用户自开发观看页点赞效果,通过调用接口可以进行点赞,默认每次请求都是一次点赞
2、接口内部进行了判断,每个观众的点赞间隔1s的限制,根据提交的观众ID来区分
3、如果有需求支持同时点多个赞,可提交非必填参数times,times最大不能超过30。*如果提交次数为n,则需n-1秒才能继续点赞
4、接口支持https
5、接口URL中的{channelId}为 频道ID

支持格式

JSON

请求方式

GET  POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前13位毫秒级时间戳,3分钟内有效
sign string 签名,32位大写MD5值
viewerId string 点赞观众的ID
times int 点赞的数目,不能超过30,提交后在times-1秒后才能再点赞

响应成功JSON示例:

{
    "code": 200, 
    "status": "success", 
    "message": "", 
    "data": 288
}

响应失败JSON示例:

未输入appId

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

appId不正确

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

时间戳错误

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

签名错误

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

未提交viewerID

{
    "code": 400,
    "status": "error",
    "message": "viewerId is required.",
    "data": ""
}

点赞间隔小于1s

{
    "code": 400,
    "status": "error",
    "message": "您的操作过快,请稍后再试",
    "data": ""
}

点赞次数times大于30

{
    "code": 400,
    "status": "error",
    "message": "设置的次数过多,请稍后再试",
    "data": ""
}

字段说明

参数名 说明
code 请求状态响应码
status 请求状态
message 错误信息
data 请求成功时为点赞数,请求错误时为空

php请求示例

<?php

//引用config.php
include 'config.php';

//接口需要的参数(非sign)赋值
$channelId = "127075";
$times = 16;
$viewerId = '123123';

$params = array(
    'appId'=>$appId,
    'times'=>$times,
    'viewerId'=>$viewerId,
    'timestamp'=>$timestamp
  );

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法

//接口请求url
$url = "http://api.polyv.net/live/v2/channels/$channelId/like?appId=$appId&timestamp=$timestamp&sign=$sign&viewerId=$viewerId&times=$times";

//输出接口请求结果
echo file_get_contents($url);

?>

签名规则(config.php文件代码查看)

http://dev.polyv.net/2018/liveproduct/l-api/rule/sign/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...