获取观看条件白名单列表

接口URL

https://api.polyv.net/live/v3/channel/auth/get-white-list

接口说明

1、接口用于获取全局或频道的观看条件白名单列表
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
rank int 1为首要条件,2为次要条件
channelId int 频道号,不传为获取全局设置
page int 要获取的页码,默认为1
pageSize int 每页数据量,默认为10
keyword string 关键词,可根据会员码和名称查询

响应成功JSON示例:

{
  "code": 200, 
  "status": "success", 
  "message": "", 
  "data": {
    "pageNumber": 1, 
    "totalPages": 4, 
    "pageSize": 5, 
    "contents": [
      {
        "name": "测试重构1", 
        "phone": "tes1", 
        "isVip": "N"
      }, 
      {
        "name": "测试重构10", 
        "phone": "tes10", 
        "isVip": "N"
      }, 
      {
        "name": "测试重构11", 
        "phone": "tes11", 
        "isVip": "N"
      }, 
      {
        "name": "测试重构12", 
        "phone": "tes12", 
        "isVip": "N"
      }, 
      {
        "name": "测试重构13", 
        "phone": "tes13", 
        "isVip": "N"
      }
    ]
  }
}

响应失败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,签名错误为401,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 分页的白名单列表数据
pageNumber 当前页码
totalPages 页面总数
pageSize 每页数据量
contents 当前页面内容
name 昵称(或备注)
phone 会员码

php请求示例

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

$channelId="204758";

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => $channelId,
  'rank' => '1',
  'page' => 1,
  'pageSize' => 5,
);

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

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

https://api.polyv.net/live/v3/channel/auth/download-white-list

接口说明

1、接口用于下载全局或频道的观看条件白名单列表
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

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

响应成功说明:

响应成功时,接口将返回文件流,格式为.xls,内容为白名单列表数据。

响应失败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,签名错误为401,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 由于成功时直接返回文件流下载,所以这里为空串

php构建下载链接示例

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

$channelId="204140";

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

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

$url = "http://api.polyv.net/live/v3/channel/auth/download-white-list?".http_build_query($params);
// 输出构建后的下载链接
echo $url;
?>

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

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

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

获取打赏设置

接口URL

http://api.polyv.net/live/v3/channel/donate/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": {
    "globalSettingEnabled": "N",
    "donateCashEnabled": "Y",
    "donateGoodEnabled": "Y",
    "donateTips": null,
    "cashMin": 0,
    "cashes": [
      0.88,
      6.66,
      8.88,
      18.88,
      66.6,
      88.8
    ],
    "goods": [
      {
        "goodName": "鲜花",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/01-flower.png",
        "goodPrice": 0,
        "goodEnabled": "Y"
      },
      {
        "goodName": "咖啡",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/02-coffee.png",
        "goodPrice": 0.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "点赞",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/03-good.png",
        "goodPrice": 1.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "掌声",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/04-applaud.png",
        "goodPrice": 2.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "666",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/05-666.png",
        "goodPrice": 6.66,
        "goodEnabled": "Y"
      },
      {
        "goodName": "小星星",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/06-star.png",
        "goodPrice": 9.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "钻石",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/07-diamond.png",
        "goodPrice": 19.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "跑车",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/08-car.png",
        "goodPrice": 29.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "火箭",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/09-rocket.png",
        "goodPrice": 66.66,
        "goodEnabled": "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 返回状态码,成功为200,参数错误为400。
status 状态,成功返回success,失败返回error
message 错误提示信息,成功时为空串
data 打赏设置的相关信息
globalSettingEnabled 是否应用全局设置,获取全局设置时,该值为null
donateCashEnabled 现金打赏开关
donateGoodEnabled 道具打赏开关
donateTips 打赏提示
cashMin 最低打赏金额
cashes 打赏金额选项
goods 打赏道具选项
goodName 道具选项名
goodImg 道具选项对应的图片
goodPrice 道具选项对应的价格
goodEnabled 是否启用该道具

php请求示例

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

$channelId="206016";

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

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

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

接口说明

1、接口用于修改频道的微信分享相关设置
2、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号
weixinShareTitle string 微信分享的标题
weixinShareDesc string 微信分享的描述

响应成功JSON示例:

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

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

频道Id格式错误

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

频道不存在

{
    "code": 404,
    "status": "error",
    "message": "channel not found.",
    "data": ""
}

频道Id非法错误

{
    "code": 400,
    "status": "error",
    "message": "illegal channel id: %s",
    "data": ""
}

字段说明

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

php请求示例

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

$params = array(
  'appId' => "填写获取到的appId",
  'timestamp' => "填写13位时间戳",
  'channelId' => "填写频道号",
  'weixinShareTitle' => "我要改标题",
  'weixinShareDesc' => "我要改描述"
);

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


$url="http://api.polyv.net/live/v3/channel/weixin-share/update";

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);
   $file_contents = curl_exec($ch);
   curl_close($ch);
   return $file_contents;
}

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

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

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

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

获取微信分享设置

接口URL

http://api.polyv.net/live/v3/channel/weixin-share/get

接口说明

1、获取频道的微信分享设置信息
2、接口支持https协议

具体功能请查看 微信分享设置

支持格式

JSON

请求方式

 GET

请求数限制

TRUE

请求参数

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

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "channelId": 108888,
        "channelName": "多码率测试频道号",
        "coverImg": "//livestatic.videocc.net/uploaded/images/2017/12/ewe26lgx61.png",
        "weixinShareTitle": "微信分享的标题",
        "weixinShareDesc": "微信分享的描述"
    }
}

响应异常JSON示例:

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

字段说明

参数名 说明
code 请求状态响应码
status 请求状态
message 错误信息
channelId 频道号
channelName 频道名称
coverImg 微信分享图标,即频道的直播图标
weixinShareTitle 微信分享的标题
weixinShareDesc 微信分享的描述

php请求示例

<?php

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

//接口需要的参数(非sign)赋值
$timestamp = 1528708015437;
$appId = "test";
$channelId = 108888;

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

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
//接口请求url
$url = "http://api.polyv.net/live/v3/channel/weixin-share/get?channelId=$channelId&appId=$appId&timestamp=$timestamp&sign=$sign";

//输出接口请求结果
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/user/category/list

接口说明

1、获取账号下所有的直播分类信息
2、接口支持https协议

支持格式

JSON

请求方式

 GET,POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
sign string 签名,为32位大写的MD5值
timestamp string 当前13位毫秒级时间戳,3分钟内有效

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "categoryId": 2034,
            "categoryName": "默认分类",
            "userId": "edvf2fpec9",
            "rank": 0
        },
        {
            "categoryId": 36,
            "categoryName": "测试测试测试",
            "userId": "edvf2fpec9",
            "rank": 1
        }
    ]
}

响应异常JSON示例:

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

字段说明

参数名 说明
code 请求状态响应码
status 请求状态
message 错误信息
categoryId 分类ID
categoryName 分类名称
userId 用户ID
rank 分类排序号,rank=0表示为默认排序

php请求示例

<?php

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

//接口需要的参数(非sign)赋值
$timestamp = 1528708015437;
$appId = "test";

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

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
//接口请求url
$url = "http://api.polyv.net/live/v3/user/category/list?appId=$appId&timestamp=$timestamp&sign=$sign";

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

?>

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

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

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

自定义授权与外部授权(视频)

自定义授权与外部授权

自定义授权的实现可以简单分成2步
1.编写验证代码
2.填写用户定义的api接口

需要注意的是,userid必须唯一,否则会出现学员被踢出观看的情况;而学员的昵称需要进行base64加密后再进行urlencode加密,否则昵称会显示乱码;
外部授权的实现逻辑跟自定义授权是类似的,外部授权比自定义授权多了一个观看页的参数验证,可以这么理解,使用外部授权,观众只能通过您网站的页面进入直播;
外部授权需要用户的api接口返回给直播系统的数据格式是json格式;

帮助文档:
自定义授权
外部授权

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

批量上传图片的接口

接口URL

http://api.polyv.net/live/v3/common/upload-image

接口说明

1、接口用于上传接口所需图片,同时获取图片地址
2、通用参数通过普通url参数传递(timestamp, appId, sign)
3、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
file MultipartFile 图片文件,支持同时上传不超过6个
type string 上传图片类型()

#图片类型的值(文件支持图片类型为.jpg|.jpeg|.png,暖场图片另外支持.gif)

类型值 说明
coverImage 频道图标, 最大不能超过为 2M
splashImage 直播引导图, 最大不能超过为 4M
logoImage 播放器logo, 最大不能超过为 2M
adminAvatar 聊天室管理员头像, 最大不能超过为 2M
assistantAvatar 助教头像, 最大不能超过为 2M
authCodeImage 授权观看二维码图片, 最大不能超过为 200K
warmImage 暖场图片, 最大不能超过为 4M
adImage 广告栏图片, 最大不能超过为 2M
startAdImage 片头广告图片, 最大不能超过为 4M
stopAdImage 暂停广告图片, 最大不能超过为 4M
goodImage 打赏道具图片, 最大不能超过为 100k
invitationImage 邀请卡图片, 最大不能超过为 4M
menuImage 频道菜单图片, 最大不能超过为 4M

注:这里的channelId,appId,timestamp,sign必须通过url传参,如:

http://api.polyv.net/live/v3/common/upload-image?appId={{appId}}&timestamp={{timestamp}}&sign={{sign}}&type={{type}}

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "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": ""
}

#上传图片个数超过6个的限制

{
    "code": 400,
    "status": "error",
    "message": "upload files over limit",
    "data": ""
}

#上传图片大小超过限制,大小请参考上面的类型表

{
    "code": 400,
    "status": "error",
    "message": "upload file size exceeds the limit",
    "data": ""
}

#上传图片类型错误

{
    "code": 400,
    "status": "error",
    "message": "upload file format error:.mp4",
    "data": ""
}

#文件上传错误

{
    "code": 400,
    "status": "error",
    "message": "undefined error",
    "data": ""
}

字段说明

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

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.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.File;
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 = "http://api.live.polyv.net/v3/common/upload-image";
        String appId = "xxxxxxxxxx";
        String key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        Map<String, String> map = new HashMap<>();
        long timestamp = System.currentTimeMillis();
        map.put("appId", appId);
        map.put("timestamp", String.valueOf(timestamp));
        map.put("type", "coverImage");

        File file = new File("C:\Users\polyv\Desktop\timg.jpg");
        List<File> files = new ArrayList<>();
        files.add(file);

        String sign = getSign(map, key);
        map.put("sign", sign);
        String content = sendHttpPost(url, map, files);
        System.out.println(content);

    }

    /**
     * 发送 post请求(带文件)
     * @param httpUrl 地址
     * @param maps 参数
     * @param fileLists 附件
     */
    public static String sendHttpPost(String httpUrl, Map<String, String> maps, List<File> fileLists) {
        HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost
        MultipartEntityBuilder meBuilder = MultipartEntityBuilder.create();
        for (String key : maps.keySet()) {
            meBuilder.addPart(key, new StringBody(maps.get(key), ContentType.TEXT_PLAIN));
        }
        for (File file : fileLists) {
            FileBody fileBody = new FileBody(file);
            meBuilder.addPart("files", fileBody);
        }
        HttpEntity reqEntity = meBuilder.build();
        httpPost.setEntity(reqEntity);
        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';


//接口需要的参数(非sign)赋值
$appId = "XXXXXXXX";
$type = "coverImage";
$imgfile = 'C:\Users\polyv\Desktop\timg.jpg';

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

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

$data = array(
      'appId' => $appId,
      'timestamp' => $timestamp,
      'sign' => $sign,
      'type'=>$type,
      'file' => new CURLFile(realpath($imgfile))
  );

$url = "http://api.polyv.net/live/v3/common/upload-image";
$ch = curl_init() or die ( curl_error() );
curl_setopt( $ch, CURLOPT_URL, $url);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 360);
$reponse = curl_exec ( $ch );
curl_close ( $ch );
print_r($reponse);
?>

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

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

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

直播数据统计功能(视频)

直播数据统计功能

统计汇总主要统计全部频道在不同日期的直播数据,统计的数据包括访问次数、观看时长、观众人数、人均观看时长、人均访问次数。

数据统计则是根据不同的条件来分类统计。
频道汇总:统计不同时间段各个频道的直播数据。
日期汇总:统计不同时间段的当天直播数据。有列表和图表两种查看方式。
地域分布:统计不同时间段观看直播的地域分布情况,分中国地区以及全球分布。右侧是top10区域占比数据排行榜。
观看终端:统计不同时间段观看直播的终端情况,右侧是top10终端占比数据排行榜。
最高在线人数:统计不同时间段的最高在线人数,右侧是最高在线人数的频道分布情况表。

频道观看详情,统计的是每个观众的观看情况,包括观看的时长,观看的地址,所在地区等等。
频道在线人数:是频道统计独有的,可以查看实时的在线人数,以及历史的并发人数。

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

设置道具打赏接口

接口URL

http://api.polyv.net/live/v3/channel/donate/update-good

接口说明

1、接口用于设置频道或者全局道具打赏(带上频道ID为设置频道道具打赏,不带频道ID默认为全局道具打赏设置)
2、通用参数通过普通url参数传递(channelId, timestamp, appId, sign),设置打赏参数的json通过请求体的方式传递
3、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号,不传为全局设置
goods 对象数组 请求体参数,道具打赏对象数组,道具对象数量必须大于0小于10
enabled string 请求体参数,现金打赏开关,不传默认开启,值为 Y/N , Y为开启

#道具对象参数

参数名 必选 类型 说明
goodName string 道具名称,不能超过5个字符
goodImg string 道具图片,不能超过120个字符(图片地址可以使用下面json字符串中的默认地址,或者通过上传图片接口上传获取图片地址)
goodPrice double 道具打赏价格
goodEnabled string 道具开关,值为 Y/N , Y为开启

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

http://api.polyv.net/live/v3/channel/donate/update-good?channelId={{channelId}}&appId={{appId}}&timestamp={{timestamp}}&sign={{sign}}

请求体json拼接

{
  "enabled": "Y",
  "goods": [
    {
      "goodName": "鲜花333",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/01-flower.png",
      "goodPrice": 0,
      "goodEnabled": "Y"
    },
    {
      "goodName": "咖啡",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/02-coffee.png",
      "goodPrice": 0.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "点赞",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/03-good.png",
      "goodPrice": 1.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "掌声",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/04-applaud.png",
      "goodPrice": 2.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "666",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/05-666.png",
      "goodPrice": 6.66,
      "goodEnabled": "Y"
    },
    {
      "goodName": "小星星",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/06-star.png",
      "goodPrice": 9.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "钻石",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/07-diamond.png",
      "goodPrice": 19.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "跑车",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/08-car.png",
      "goodPrice": 29.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "火箭233",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/09-rocket.png",
      "goodPrice": 66.66,
      "goodEnabled": "Y"
    }
  ]
}

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "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": ""
}

#channelId非法错误

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

#json为空或者json解析错误

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

#json中的goods数量限制

{
    "code": 400,
    "status": "error",
    "message": "goods over limit",
    "data": ""
}

#json中的goods的名称字符限制

{
    "code": 400,
    "status": "error",
    "message": "goods name over limit",
    "data": ""
}

#json中的goods的图片地址字符限制

{
    "code": 400,
    "status": "error",
    "message": "goods image length over limit",
    "data": ""
}

#json中的goods的价格数据类型错误

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

字段说明

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

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 = "http://api.polyv.net/live/v3/channel/donate/update-good";
        int channelId = 209796;
        String appId = "XXXXXX";
        String key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        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 = "{\"goods\":[{\"goodName\":\"鲜花333\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/01-flower.png\",\"goodPrice\":0,\"goodEnabled\":\"Y\"},{\"goodName\":\"咖啡\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/02-coffee.png\",\"goodPrice\":0.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"点赞\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/03-good.png\",\"goodPrice\":1.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"掌声\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/04-applaud.png\",\"goodPrice\":2.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"666\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/05-666.png\",\"goodPrice\":6.66,\"goodEnabled\":\"Y\"},{\"goodName\":\"小星星\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/06-star.png\",\"goodPrice\":9.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"钻石\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/07-diamond.png\",\"goodPrice\":19.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"跑车\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/08-car.png\",\"goodPrice\":29.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"火箭233\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/09-rocket.png\",\"goodPrice\":66.66,\"goodEnabled\":\"Y\"}]}";
        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' => "209796"
);

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

$json = '{
  "enabled": "Y",
  "goods": [
    {
      "goodName": "鲜花333",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/01-flower.png",
      "goodPrice": 0,
      "goodEnabled": "Y"
    },
    {
      "goodName": "咖啡",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/02-coffee.png",
      "goodPrice": 0.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "点赞",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/03-good.png",
      "goodPrice": 1.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "掌声",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/04-applaud.png",
      "goodPrice": 2.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "666",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/05-666.png",
      "goodPrice": 6.66,
      "goodEnabled": "Y"
    },
    {
      "goodName": "小星星",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/06-star.png",
      "goodPrice": 9.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "钻石",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/07-diamond.png",
      "goodPrice": 19.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "跑车",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/08-car.png",
      "goodPrice": 29.99,
      "goodEnabled": "Y"
    },
    {
      "goodName": "火箭233",
      "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/09-rocket.png",
      "goodPrice": 66.66,
      "goodEnabled": "Y"
    }
  ]
}';

$params["sign"] = $sign;
$url="http://api.polyv.net/live/v3/channel/donate/update-good?".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...