获取频道的回放开关

接口URL

https://api.polyv.net/live/v3/channel/playback/get-enabled

接口说明

1、接口用于获取频道的回放开关
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号,不传该参数为获取全局设置

响应成功JSON示例:

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

响应失败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 成功响应时为回放开关,Y(开启)、N(关闭)

php请求示例

<?php
//引用config.php
include '/srv/http/config.php';
$channelId = '要查询的频道号';
$params = array(
  'appId' => $appId,
  'channelId' => $channelId,
  'timestamp' => $timestamp
);

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

$url = "http://api.polyv.net/live/v3/channel/playback/get-enabled?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_POST, 1);
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/v3/channel/menu/update-rank

接口说明

1、作用:修改直播频道的菜单的顺序
2、接口支持https协议

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前时间的秒级时间戳(13位)
sign string 签名,为32位大写的MD5值
channelId int 频道号
menuIds string 频道菜单ID列表,必须是完整的列表(不能多也不能少),表示按该顺序排列菜单

操作成功响应示例

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

操作失败响应示例

签名错误

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

缺少参数 menuIds

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

菜单ID列表错误(缺少菜单ID,或者有多余的、错误的菜单ID)

{
    "code": 400,
    "status": "error"
    "message": "illegal menu id: menuIds",
    "data": ""
}

响应字段说明

名称 类型 说明
code string 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status string 成功为success,失败为error
message string 错误时为错误提示消息

php请求示例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => '123456',
  'menuIds' => '123,456'
);

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

$params["sign"] = $sign;
$url="http://api.polyv.net/live/v3/channel/menu/update-rank?".http_build_query($params);

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);
?>

java请求示例

package com.live;

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;

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 com.live.util.EncryptionUtils;

public class Demo {


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

    public static void main(String[] args) {

        String url = "http://api.polyv.net/live/v3/channel/menu/update-rank";
        String appId = "appId";
        String key = "secretKey";
        Map<String, String> map = new HashMap<>();
        map.put("appId", appId);
        map.put("timestamp", String.valueOf(System.currentTimeMillis()));
        map.put("channelId", "123456");
        map.put("menuIds", "123,456");

        String sign = getSign(map, key);
        map.put("sign", sign);

        String body = "";
        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);

        System.out.println(urlStr);
        // 创建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;
    }
}

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

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

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

删除指定菜单

接口URL

https://api.polyv.net/live/v3/channel/menu/delete

接口说明

1、接口用于删除指定的频道菜单,支持批量
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
menuIds string 菜单id,指定多个以英文逗号,分隔

响应成功JSON示例:

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

响应失败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": ""
}

menuId分割后为空

{
  "code": 400, 
  "status": "error", 
  "message": "param length is incorrect: menuIds", 
  "data": ""
}

菜单不存在

{
  "code": 400, 
  "status": "error", 
  "message": "illegal menu id: test", 
  "data": ""
}

菜单类型不能删除

{
  "code": 400, 
  "status": "error", 
  "message": "can't delete special menu type", 
  "data": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 成功响应时为本次成功删除的个数

php请求示例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'menuIds' => "9991391d9d,ea4375fcfb"
);

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

$url = "http://api.polyv.net/live/v3/channel/menu/delete?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_POST, 1);
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

https://api.polyv.net/live/v3/channel/playback/sort

接口说明

1、接口用于排序回放列表。
2、通用参数通过普通url参数传递(channelId, timestamp, appId, sign),排序参数的json通过请求体的方式传递
3、接口支持https。

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号
videoIds string数组 完整回放视频ID列表,存放在请求体中,请求视频ID数量必须和回放列表数量一致,且不能少或者缺或者多

响应成功JSON示例:

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

响应失败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": ""
}

请求体未传递videoIds错误

{
  "code": 400, 
  "status": "error",
  "message": "param validate error",
  "data": ""
}

数据库查询不到回放列表的视频错误

{
  "code": 400,
  "status": "error",
  "message": "playback video list is empty",
  "data": ""
}

回放视频ID错误(请求视频ID数量必须和回放列表数量一致,且不能少或者缺或者多)

{
  "code": 400,
  "status": "error",
  "message": "playback videoId error",
  "data": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 修改成功过时为true

php请求示例

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

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

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

$json = '{
    "videoIds": ["dsdadrerwf", "dadadaderr"]
}';

$params["sign"] = $sign;
$url="http://api.polyv.net/live/live/v3/channel/playback/sort?".http_build_query($params);

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...

修改功能开关设置

接口URL

https://api.polyv.net/live/v3/channel/switch/update

接口说明

1、接口用于修改功能开关设置,可修改全局开关设置或频道开关设置
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号,不传该参数为获取全局设置
type string 开关类型
enabled string 开关值,Y或N

开关类型

type 描述
isClosePreview 是否关闭系统观看页,Y时表示关闭
mobileWatch 是否开启移动端系统观看页
mobileAudio 是否开启移动端音视频切换
autoPlay 是否开启播放器自动播放功能
booking 是否开启预约功能
redPack 是否开启红包功能
shareBtnEnabled 是否开启分享功能
chat 是否开启聊天室
closeChaterList 是否关闭在线列表,Y时表示关闭
consultingMenu 是否开启咨询提问
closeDanmu 是否关闭弹幕功能,Y时表示关闭
praise 是否开启点赞语功能
welcome 是否开启欢迎语功能
chatPlayBack 是否开启聊天回放
viewerSendImgEnabled 是否开启观众发送图片

注:isClosePreview当enabled值为Y时,表示的是关闭系统观看页;closeDanmu当enabled值为Y时,表示的是关闭弹幕;closeChaterList当enabled值为Y时,表示的是关闭在线列表

响应成功JSON示例:

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

响应失败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 修改成功过时为true

php请求示例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => '206204',
  'type' => 'viewerSendImgEnabled',
  'enabled' => 'N'
);

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

$url = "http://api.polyv.net/live/v3/channel/switch/update?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_POST, 1);
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

https://api.polyv.net/live/v3/channel/switch/get

接口说明

1、接口用于获取开关设置,可获取全局开关设置或频道开关设置
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号,不传该参数为获取全局设置

响应成功JSON示例:

{
  "code": 200, 
  "status": "success", 
  "message": "", 
  "data": [
    {
      "type": "isClosePreview", 
      "enabled": "N"
    }, 
    {
      "type": "mobileWatch", 
      "enabled": "Y"
    }, 
    {
      "type": "mobileAudio", 
      "enabled": "Y"
    }, 
    {
      "type": "autoPlay", 
      "enabled": "Y"
    }, 
    {
      "type": "booking", 
      "enabled": "Y"
    }, 
    {
      "type": "redPack", 
      "enabled": "Y"
    }, 
    {
      "type": "shareBtnEnabled", 
      "enabled": "Y"
    }, 
    {
      "type": "chat", 
      "enabled": "Y"
    }, 
    {
      "type": "closeChaterList", 
      "enabled": "N"
    }, 
    {
      "type": "consultingMenu", 
      "enabled": "Y"
    }, 
    {
      "type": "closeDanmu", 
      "enabled": "N"
    }, 
    {
      "type": "praise", 
      "enabled": "Y"
    }, 
    {
      "type": "welcome", 
      "enabled": "Y"
    }, 
    {
      "type": "chatPlayBack", 
      "enabled": "Y"
    }, 
    {
      "type": "viewerSendImgEnabled", 
      "enabled": "Y"
    }
  ]
}

响应失败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 成功响应时为当前开关设置项
type 开关类型
enabled 是否已打开开关

注:isClosePreview当enabled值为Y时,表示的是关闭系统观看页;closeDanmu当enabled值为Y时,表示的是关闭弹幕;closeChaterList当enabled值为Y时,表示的是关闭在线列表

php请求示例

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

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

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

$url = "http://api.polyv.net/live/v3/channel/switch/get?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_POST, 1);
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/v3/channel/basic/batch-delete

接口说明

1、作用:批量删除直播频道
2、接口支持https协议

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前时间的秒级时间戳(13位)
sign string 签名,为32位大写的MD5值
channelIds json 频道ID列表,每次最多删除100个频道, 必须放在请求体中

请求体示例

{
    "channelIds": [123001, 123002, 123003]
}

操作成功响应示例

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

操作失败响应示例

留意,如果响应失败,则表示全部频道都失败,不会有部份成功、部份失败的结果

签名错误

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

请求体json格式错误

{
    "code": 400,
    "status": "error"
    "message": "json format error",
    "data": ""
}

channelIds 列表中的频道ID数超过上限(100个)

{
    "code": 400,
    "status": "error"
    "message": "channel batch count over limit",
    "data": ""
}

channelIds 列表中有错误的频道ID(会输出第一个错误的频道ID)

{
    "code": 400,
    "status": "error"
    "message": "channel not found: 123456",
    "data": ""
}

响应字段说明

名称 类型 说明
code string 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status string 成功为success,失败为error
message string 错误时为错误提示消息
data boolean 成功时为true

php请求示例

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

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

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

$json = '{
    "channelIds": [123001, 123002, 123003]
}';

$params["sign"] = $sign;
$url="http://api.polyv.net/live/v3/channel/basic/batch-delete?".http_build_query($params);

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);
?>

java请求示例

package com.live;

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;

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 com.live.util.EncryptionUtils;

public class Demo {


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

    public static void main(String[] args) {

        String url = "http://api.polyv.net/live/v3/channel/basic/batch-delete";
        String appId = "appId";
        String key = "secretKey";
        Map<String, String> map = new HashMap<>();
        map.put("appId", appId);
        map.put("timestamp", String.valueOf(System.currentTimeMillis()));

        String sign = getSign(map, key);
        map.put("sign", sign);

        String body = "{\"channelIds\":[123001, 123002, 123003]}";
        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);

        System.out.println(urlStr);
        // 创建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;
    }
}

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

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

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

批量创建频道

接口URL

http://api.polyv.net/live/v3/channel/basic/batch-create

接口说明

1、作用:批量创建直播频道
2、接口支持https协议

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前时间的秒级时间戳(13位)
sign string 签名,为32位大写的MD5值
channels json 频道列表,每次最多创建100个频道, 必须放在请求体中

请求体示例

{
    "channels": [
        {
            "name": "abc",
            "channelPasswd": "xyz"
        },
        {
            "name": "def",
            "channelPasswd": "xyz",
            "autoPlay": 0,
            "playerColor": "#454545",
            "scene": "ppt",
            "categoryId": 123
        }
    ]
}

请求体字段说明

参数名 必选 类型 说明
name string 频道名称
channelPasswd string 频道密码
courseId string 课程号
autoPlay int 是否自动播放,0/1,默认1
注意,如果该值为空,则该频道会使用全局的“功能开关设置”。
如果非空,则会使用频道的“功能开关设置”。
playerColor string 播放器控制栏颜色,默认:#666666
scene string 直播场景:
alone 活动拍摄
ppt 三分屏
topclass 大班课
categoryId int 新建频道的所属分类,如果不提交,则为默认分类(分类ID可通过“获取直播分类”接口得到)

操作成功响应示例

{
    "code": 200,
    "status": "success"
    "message": "",
    "data": {
        "channels": [
            {
                "channelId": 123456,
                "userId": "e6b23c6f51",
                "name": "abc",
                "publisher": null,
                "description": "",
                "url": "rtmp://push2.videocc.net/recordfe/e6b23c6f5120180813142756453",
                "stream": "e6b23c6f5120180813142756453",
                "logoImage": "",
                "logoOpacity": 1.0,
                "logoPosition": "",
                "logoHref": "",
                "coverImage": "",
                "coverHref": "",
                "waitImage": "",
                "waitHref": "",
                "cutoffImage": "",
                "cutoffHref": "",
                "advertType": "IMAGE",
                "advertDuration": 5,
                "advertWidth": 0,
                "advertHeight": 0,
                "advertImage": "",
                "advertHref": "",
                "advertFlvVid": "",
                "advertFlvUrl": "",
                "playerColor": "#666666",
                "autoPlay": true,
                "warmUpFlv": "",
                "passwdRestrict": false,
                "passwdEncrypted": "",
                "isOnlyAudio": "N",
                "isLowLatency": "N",
                "m3u8Url": "http://pullh.videocc.net/recordfe/e6b23c6f5120180813142756453/playlist.m3u8",
                "m3u8Url1": "",
                "m3u8Url2": "",
                "m3u8Url3": "",
                "currentTimeMillis": 1534141677347
            }
        ]
    }
}

操作失败响应示例

留意,如果响应失败,则表示全部频道都失败,不会有部份成功、部份失败的结果

签名错误

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

请求体json格式错误

{
    "code": 400,
    "status": "error"
    "message": "json format error",
    "data": ""
}

channels 列表中的频道数超过上限(100个)

{
    "code": 400,
    "status": "error"
    "message": "channel batch count over limit",
    "data": ""
}

现有频道数加上新建频道数的总数,超过用户可创建的频道总数

{
    "code": 400,
    "status": "error"
    "message": "channel count reached the limit",
    "data": ""
}

频道名称或者频道密码为空

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

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

courseId 长度超过限制(100个字符)

{
    "code": 400,
    "status": "error"
    "message": "param length is incorrect: courseId",
    "data": ""
}

自动播放 autoPlay 错误(不是1或者0)

{
    "code": 400,
    "status": "error"
    "message": "param validate error",
    "data": ""
}

播放器颜色 playerColor 错误(正确的颜色值例如 #666666)

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

直播场景 scene 错误

{
    "code": 400,
    "status": "error"
    "message": "invalid live scene",
    "data": ""
}

频道分类ID categoryId 错误

{
    "code": 400,
    "status": "error"
    "message": "illegal category id: categoryId",
    "data": ""
}

响应字段说明

名称 类型 说明
code string 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status string 成功为success,失败为error
message string 错误时为错误提示消息
channelId string 直播频道ID
userId string 直播用户ID
name string 直播频道名称
description string 直播频道描述
url string 直播推流地址
stream string 直播流名称
logoImage string 播放器logo
logoOpacity float Logo不透明度,1 表示完全不透明,0 表示完全透明
logoPosition string logo位置:
tl 左上,
tr 右上,
bl 左下,
br 右下。
logoHref string Logo的跳转链接
coverImage string 播放前显示的封面图
coverHref string 封面图的跳转链接
waitImage string 等待推流时的显示图片
waitHref string 等待推流时显示图片的跳转链接
cutoffImage string 切断流时的显示图片
cutoffHref string 切断流时显示图片的跳转链接
advertType string 片头广告类型:
NONE 无广告,
IMAGE 图片,
FLV 视频。
advertDuration string 广告时长(秒)
advertWidth string 广告区域宽度(像素)
advertHeight string 广告区域高度(像素)
advertImage string 图片广告
advertHref string 广告的跳转链接
advertFlvVid string 视频广告ID
advertFlvUrl string 视频广告链接
playerColor string 播放器控制栏颜色,例如 #666666
autoPlay boolean 是否自动播放
warmUpFlv string 暖场视频链接
passwdRestrict boolean 观看密码限制,需要输入观看密码才能播放流
passwdEncrypted string 观看密码加密后的密文
isOnlyAudio string Y 音频模式,
N 普通模式。
isLowLatency string 低延迟
m3u8Url string 直播拉流(播放)m3u8地址
m3u8Url1 string 直播拉流(播放)m3u8地址1
m3u8Url2 string 直播拉流(播放)m3u8地址2
m3u8Url3 string 直播拉流(播放)m3u8地址3
currentTimeMillis timestamp 当前时间戳(毫秒)

php请求示例

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

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

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

$json = '{
    "channels": [{
        "name": "abc",
        "channelPasswd": "xyz"
    }]
}';

$params["sign"] = $sign;
$url="http://api.polyv.net/live/v3/channel/basic/batch-create?".http_build_query($params);

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);
?>

java请求示例

package com.live;

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;

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 com.live.util.EncryptionUtils;

public class Demo {


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

    public static void main(String[] args) {

        String url = "http://api.polyv.net/live/v3/channel/basic/batch-create";
        String appId = "appId";
        String key = "secretKey";
        Map<String, String> map = new HashMap<>();
        map.put("appId", appId);
        map.put("timestamp", String.valueOf(System.currentTimeMillis()));

        String sign = getSign(map, key);
        map.put("sign", sign);

        String body = "{\"channels\":[{\"name\": \"abc\", \"channelPasswd\": \"xyz\"}]}";
        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);

        System.out.println(urlStr);
        // 创建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;
    }
}

签名规则(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",
            "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",
            "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...