获取授权和连麦的token

接口URL

http://api.polyv.net/live/v3/channel/common/get-token

接口说明

1、接口用于获取授权和连麦的token
2、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

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

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
"mediaChannelKey": "e2355436235ba12d4c56493b575afed38f9f061d044f54d93c30f01463ffea852a7119c6195c6abf51b4682bc596bf5962eddc6cbf82784a1e5309ac52220ef7e66e4e7eb69a4e80081056972d5a9cb3bb723a0cb090702eef99369d479482b3bad99e5ec50eae5607b82c58da59aac3eada29fe6d753ef358d064ee308e406b3091f5256a77251001f99b6815651f18982da983b58c79d9caedd5ccec3f20ecd3dde7ba370f3c0ca0aa8c3ef088148523019f06e224d030b871da390c4a1a1c646e26684895d544dbba47751c535d07ea765fcf0cdfe8fe3de1538e4fe69eecadfd4a8b431aa4b00bc5dbccdb996ea3b7f962da2ecc21b6b14ba70c33601c53c3aa8d8e4857c111fa076e47e3a6eafc9601b87c079361f2d0f3cb4b31df2ff088ccb9428abe324ecb9e07e2fb8f48e40ab2ef3e119cfd93b15259bfa390938485a8fcd2e200dadeefe15a0516b7f61736cbe5bf48564d100e28ff64f979ebf42eadd3a0f3d58565d1ab619884d78c29",
"token": "71b961e6b2a68cde9559966b2f46d4e0"
}
}

响应字段说明

参数名 说明
code 状态码,成功为200,签名失败为403,参数错误为400,服务端错误为500
status 成功为success,错误时为error
message 成功为"",错误时为错误描述信息
data.token 链接接口需要的token值
data.mediaChannelKey 连麦需要的key

响应失败JSON示例:

参数错误

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

未输入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": ""
}

php请求示例

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

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

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

$url = "http://api.polyv.net/live/v3/channel/common/get-token?".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

http://api.polyv.net/live/v3/channel/playback/set-setting

接口说明

1、接口用于设置回放设置
2、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId string 频道号
playbackEnabled string 回放开关,Y-开启,N-关闭
type string 回放方式,single-单个回放,list-列表回放
origin string 回放来源,record-暂存,playback-回放列表,vod-点播列表
videoId string 单个回放的视频id

响应成功JSON示例:

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

响应字段说明

参数名 说明
code 状态码,成功为200,签名失败为403,参数错误为400,服务端错误为500
status 成功为success,错误时为error
message 成功为"",错误时为错误描述信息
data 成功时为true,错误时为""

响应失败JSON示例:

参数错误

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

未输入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": "scene operation limited",
    "data": ""
}

三分屏操作点播列表

{
    "code": 400,
    "status": "error",
    "message": "scene operation limited",
    "data": ""
}

暂存不支持列表

{
    "code": 400,
    "status": "error",
    "message": "unsupported record list",
    "data": ""
}

php请求示例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' =>  195770,
  'playbackEnabled' => 'Y',
  'type' => 'list',
  'origin' => 'playback'
);

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

$url = "http://api.polyv.net/live/v3/channel/playback/set-setting?".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

http://api.polyv.net/live/v3/channel/document/list

接口说明

1、接口用于频道文档列表接口
2、接口支持https

支持格式

JSON

请求方式

GET

请求参数

参数名 必选 类型 说明
appId string 管理员的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号
status String 文档状态,不传查询所有(“normal” :正常,“delete”:删除,“waitUpload”:等待上传,“failUpload”:上传失败,"waitConvert":转换PPT中,"failConvert":转换PPT失败)
page int 第几页,默认不传显示第一页
limit int 每页显示几条数据,默认不传显示100条
isShowUrl string 是否展示PPT原文件地址,该参数不传默认不展示,’Y‘:是,’N‘:否

响应成功JSON示例:

// 响应成功
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
    "pageSize": 10,
    "pageNumber": 1,
    "totalItems": 1,
    "contents": [{
        "autoId": 111111,
        "fileId": "xxxxxxxxx",
        "fileName": "关于xxxx的通知.pdf",
        "fileUrl": "http://doc-2.polyv.net/sources/20190614/xxxxxxxxxxxxxxxxxxxx.pdf",
        "fileType": ".pdf",
        "totalPage": 1,
        "channelId": "254318",
        "status": "normal",
        "createTime": 1560476703000,
        "convertType": "common",
        "type": "new",
        "previewImage": "http://doc-2.polyv.net/images/2019/06/xxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxx_0000_s.jpeg"
    }],
    "startRow": 1,
    "firstPage": true,
    "lastPage": true,
    "nextPageNumber": 1,
    "prePageNumber": 1,
    "totalPages": 1,
    "endRow": 5,
    "limit": 5,
    "offset": 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 响应代码,成功为200,失败为400,签名错误为403,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 分页的文档列表
data.pageNumber 当前页码
data.totalPages 页面总数
data.pageSize 每页数据量
data.contents 当前页面内容
data.contents[0].autoId 文档ID
data.contents[0].fileId 文件ID
data.contents[0].fileName 文件名
data.contents[0].fileUrl 文件url
data.contents[0].fileType 文件类型
data.contents[0].totalPage PPT总页数
data.contents[0].channelId 频道ID
data.contents[0].status ppt转换状态(“normal” :正常,“delete”:删除,“waitUpload”:等待上传,“failUpload”:上传失败,"waitConvert":转换PPT中,"failConvert":转换PPT失败)
data.contents[0].createTime 创建时间
data.contents[0].convertType 转换类型("common":"普通PPT","animate": "动画PPT")
data.contents[0].type 类型,区分旧版PPT还是新版PPT,新版值为“new”,旧版值为“old”
data.contents[0].previewImage ppt预览小图地址

请求示例

<?php

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

//接口URL上变量
$channelId = "123456";
//接口需要的参数(非sign)赋值
$params = array(
    'appId'=>$appId,
    'timestamp'=>$timestamp,
    'channelId'=>$channelId
  );

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

//接口请求url
$url = "http://api.polyv.net/live/v3/channel/document/list?appId=".$appId."&sign=".$sign."&timestamp=".$timestamp."&channelId=".$channelId;
//输出接口请求结果
echo file_get_contents($url);

?>

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

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

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

添加菜单

接口URL

http://api.polyv.net/live/v3/channel/menu/add

接口说明

1、作用:添加一个频道菜单
2、接口支持https协议

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前时间的秒级时间戳(13位)
sign string 签名,为32位大写的MD5值
channelId int 频道号
name string 菜单名称
type string 菜单类型
desc 直播介绍
chat 互动聊天
quiz 咨询提问
text 图文菜单
iframe推广外链
content string 菜单内容。
当菜单类型为直播介绍、图文菜单时,该值为菜单的内容。
当菜单类型为外链推广时,该值为外链链接地址。

操作成功响应示例

{
  "code": 200,
  "message": "",
  "data": {
    "menuId": "3b650cf438",
    "menuType": "iframe",
    "name": "推广菜单",
    "ordered": 6,
    "content": "http://polyv.net"
  }
}

操作失败响应示例

签名错误

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

缺少参数

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

参数长度过长

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

菜单类型错误

{
    "code": 400,
    "status": "error"
    "message": "invalid menu type",
    "data": ""
}

已存在该类型的菜单(除 text、iframe 类型外,其他菜单都具有唯一性,重复添加相同类型时会返回错误)

{
    "code": 400,
    "status": "error"
    "message": "menu already exist",
    "data": ""
}

菜单数已达到上限(“咨询提问”之外,最多可以有6个菜单)

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

响应字段说明

名称 类型 说明
code string 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status string 成功为success,失败为error
message string 错误时为错误提示消息
menuId string 菜单ID
menuType string 菜单类型
desc 直播介绍
chat 互动聊天
quiz 咨询提问
text 图文菜单
iframe推广外链
name string 菜单名称
ordered string 菜单顺序,值越小,越靠前。新添加的菜单默认位于最后。
content string 菜单内容

php请求示例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => '123456',
  'name' => '菜单名称',
  'type' => 'text',
  'content' => '菜单内容'
);

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

$params["sign"] = $sign;
$url="http://api.polyv.net/live/v3/channel/menu/add?".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/add";
        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("name", "菜单名称");
        map.put("type", "text");
        map.put("content", "菜单内容");

        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

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/statistics/get-max-history-viewer

接口说明

1、接口用于获取频道在某个日期区间的最大历史并发人数
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

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

响应成功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: dsadasd", 
  "data": ""
}

日期范围错误

{
  "code": 400, 
  "status": "error", 
  "message": "date range error", 
  "data": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 日期区间内最大的历史并发人数

php请求示例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => 195770,
  'startTime' => 1546272000000,
  'endTime' => 1548950400000
);

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

$url = "http://api.polyv.net/live/v3/channel/statistics/get-max-history-viewer?".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, 0);
$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/playback/add

接口说明

1、作用:添加账号对应的点播视频作为直播频道下的回放视频。
2、接口支持https协议

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前13位毫秒级时间戳,3分钟内有效
channelId int 频道号
vid string 要添加为回放的的点播视频
sign string 签名,32位大写MD5值
setAsDefault string 添加到回放列表中的位置,Y (回放列表中置顶),N 回放列表中置底,不传默认为 N
listType string playback-回放列表,vod-点播列表; 默认普通直播场景为vod,三分屏为playback

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "videoId": "bd75a9c155",
        "videoPoolId": "8205ac89d3981cc8070eef326039527f",
        "userId": "8205ac89d3",
        "channelId": 108888,
        "title": "123",
        "firstImage": "8205ac89d3/f/8205ac89d3981cc8070eef326039527f_0.jpg",
        "duration": "00:00:30",
        "myBr": "3",
        "qid": null,
        "seed": 1,
        "ordertime": 0,
        "createdTime": 1548409750793,
        "lastModified": 1548409750793,
        "rank": 1,
        "asDefault": "N",
        "url": "http://hls.videocc.net/source/8205ac89d3/f/8205ac89d3981cc8070eef326039527f_3.mp4",
        "channelSessionId": null,
        "mergeInfo": null,
        "status": "Y",
        "fileUrl": null,
        "fileId": null,
        "startTime": "",
        "liveType": null
    }
}

字段说明

参数名 说明
status 响应状态
data 响应结果
message 异常错误信息 |
videoId 直播系统生成的id
videoPoolId 点播视频vid
userId 点播后台用户id
channelId 回放视频对应的直播频道id
title 视频标题
firstImage 视频首图
duration 视频长度
myBr 默认视频的播放清晰度,1为流畅,2为高清,3为超清
qid 访客信息收集id
seed 视频加密状态,1表示为加密状态,0为非加密
createdTime 添加为回放视频的日期
lastModified 视频最后修改日期
asDefault 是否为默认播放视频,值为Y/N(已弃用)
url 视频播放地址,注:如果视频为加密视频,则此地址无法访问
channelSessionId 用于PPT请求数据,与PPT直播的回放相关,普通直播回放值为null
mergeInfo 视频合并信息
startTime 直播开始时间
liveType 回放视频的场景类型

php请求示例

<?php

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

//接口需要的参数(非sign)赋值
$appId = "xxxx";
$channelId = "xxx";
$vid = "xxxxxxxx";
$setAsDefault = "Y";

$params = array(
    'appId'=>$appId,
    'channelId'=>$channelId,
    'vid'=>$vid,
    'setAsDefault'=>$setAsDefault
  );

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

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

$url = "http://api.polyv.net/live/v3/channel/playback/add?".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, 0);
$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/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...

查询频道的回放开关状态

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