频道图片资源快捷设置

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

设置道具打赏

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

设置现金打赏

接口URL

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

接口说明

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 频道号,不传为全局设置
cashes double数组 请求体参数,现金打赏数额数组,数组的长度必须为6
cashMin double 请求体参数,现金打赏自定义最小金额
enabled string 请求体参数,现金打赏开关,不传默认开启,值为 Y/N , Y为开启

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

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

请求体json拼接

{
   "cashes": [0.88,6.66,8.88,18.11,66.60,88.80],
   "cashMin": 0.02,
   "enabled": "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中的cashes和cashMin的数字类型校验错误

{
    "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.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;

/**
 * Created by huangyufeng on 2017/7/27.
 */
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/channel/donate/update-cash";
        int channelId = 209796;
        String appId = "xxxxxxx";
        String key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        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 = "{\"cashes\": [0.11,6.66,8.88,18.11,66.60,88.80],\"cashMin\": 0.02,\"enabled\": \"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 = '{
    "cashes": [0.88,6.66,8.88,18.11,66.60,88.80],
    "cashMin": 0.02,
    "enabled": "Y"
}';

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

http://api.polyv.net/live/v3/channel/common/update-global-enabled

接口说明

1、接口用于设置〔是否应用默认设置〕,包括的功能有打赏设置,广告设置,观看条件设置,跑马灯,功能开关,播放限制
2、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号
globalEnabledType string 功能类型
enabled string Y或N,Y开启,N关闭
功能类型 说明
auth 观看条件设置
switch 功能开关设置
marquee 跑马灯设置
restrict 播放限制设置
donate 打赏设置
advert 广告设置

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

开关参数错误

{
    "code": 400,
    "status": "error",
    "message": "param is not boolean (Y / N)",
    "data": ""
}

字段说明

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

php请求示例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => "206204",
  'globalEnabledType' => "auth",
  'enabled' => "Y"
);

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

$url="http://api.polyv.net/live/v3/channel/common/update-global-enabled";

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/auth/update

接口说明

1、接口用于设置频道或全局的观看条件
2、主要观看条件为关闭时,次要观看条件不能为打开,否则返回参数错误
3、主要观看条件和次要观看条件为相同时,不能够同时打开,否则返回参数错误
4、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

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

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

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

authSettings详细说明

通用参数说明

参数名 必选 类型 说明
rank int 主要观看条件为1,次要观看条件为2
enabled string 是否开启,Y为开启,N为关闭
authType string 付费观看-pay,验证码观看-code,白名单观看-phone,登记观看-info,自定义授权观看-custom,外部授权-external

开启或关闭观看条件

{
    "authSettings": [{
        "rank": 1,
        "enabled": "N"
    },
    {
        "rank": 2,
        "enabled": "N"
    }]
}

付费观看

主要观看条件为付费观看,次要观看条件关闭,json数据格式如下:

{
    "authSettings": [{
        "rank": 1,
        "enabled": "Y",
        "authType": "pay",
        "payAuthTips": "给钱才能看",
        "price": "998",
        "watchEndTime": null,
        "validTimePeriod": null
    },
    {
        "rank": 2,
        "enabled": "N"
    }
    ]
}

参数说明

参数名 必选 类型 说明
payAuthTips string 欢迎语标题
price int 价格,单位为元
watchEndTime string 付费有效截止日期,格式为yyyy-MM-dd HH:mm
validTimePeriod int 付费有效时长,单位天

注:当watchEndTime和validTimePeriod都为空时,表示付费永久有效

验证码观看和白名单观看

主要观看条件为验证码观看,次要观看条件为白名单观看

设置观看条件为白名单观看时,必须已经存在白名单数据,否则设置失败。白名单可通过后台上传也可以通过上传白名单接口上传

{
    "authSettings": [{
        "rank": 1,
        "enabled": "Y",
        "authType": "code",
        "authCode": "polyv",
        "qcodeTips": "扫码关注XXX,获得观看码",
        "qcodeImg": "http://livestatic.polyv.net/xxxxx.png"
    },
    {
        "rank": 2,
        "enabled": "Y",
        "authType": "phone",
        "authTips": "会员通道"
    }
    ]
}

验证码观看参数说明

参数名 必选 类型 说明
authCode string 验证码
qcodeTips string 提示文案
qcodeImg string 公众号二维码地址

白名单观看参数说明

参数名 必选 类型 说明
authTips string 提示文案

登记观看

主要观看条件为登记观看

{
    "authSettings": [{
        "rank": 1,
        "enabled": "Y",
        "authType": "info",
        "infoFields": [
            {
                    "name": "姓名",
                    "type": "name",
                    "options": null,
                    "placeholder": null
                },
                {
                    "name": "从哪里来???",
                    "type": "text",
                    "options": null,
                    "placeholder": "请填写"
                },
                {
                    "name": "性别",
                    "type": "option",
                    "options": "男,女,你猜",
                    "placeholder": "请填写"
                },
                {   "name": "年龄",
                    "type": "number",
                    "options": null,
                    "placeholder": "请问你多大"
                },
                {
                    "name": "手机号",
                    "type": "mobile",
                    "options": null,
                    "placeholder": "留下你的号码"
                }
        ]
    }
    ]
}

登记观看参数说明

参数名 必选 类型 说明
infoFields json 登记观看信息,上线为5个
name string 登记信息名,最多为8字符
type string 登记类型,姓名-name,文本-text,手机号码-mobile,数字-number,下拉选项-option
options string 下拉选项时,下拉的选项值,以英文逗号分割。选项个数上限为8个;选项内容最多为8字符
placeholder string 文本框输入提示,最多为8字符

外部授权和自定义授权

主要观看条件为外部授权观看,次要条件为自定义授权观看

{
    "authSettings": [{
        "rank": 1,
        "enabled": "Y",
        "authType": "external",
        "externalKey": "zzxxccvvbb",
        "externalUri": "http://polyv.net",
        "externalRedirectUri": "http://12306.cn"
        },
    {
        "rank": 2,
        "enabled": "Y",
        "authType": "custom",
        "customKey": "aabbccddee",
        "customUri": "http://www.polyv.net"
    }
    ]
}

外部授权参数说明

参数名 必选 类型 说明
externalKey string SecretKey
externalUri string 自定义url
externalRedirectUri string 跳转地址

自定义授权json参数

参数名 必选 类型 说明
customKey string SecretKey
customUri string 自定义url

注:以上的json示例为同时设置两个观看条件,可以通过authSettings中只传递一个json对象来选择只控制主要观看条件或者次要观看条件。

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

字段说明

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

php请求示例

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

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

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

$json = '{
    "authSettings": [{
        "rank": 1,
        "enabled": "N"
    },
    {
        "rank": 2,
        "enabled": "N"
    }]
}';

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

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/auth/update";
        String channelId = "频道号";
        String appId = "appId";
        String key = "secretKey";
        Map<String, String> map = new HashMap<>();
        String timestamp = Long.toString(System.currentTimeMillis());
        map.put("appId", appId);
        map.put("timestamp", "1533893354000");
        map.put("channelId", channelId);

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

        String body = "{\"authSettings\":[{\"rank\":1,\"enabled\":\"N\"},{\"rank\":2,\"enabled\":\"N\"}]}";
        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/auth/upload-white-list

接口说明

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

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号,无该参数为全局设置
rank int 主要观看条件为1,次要观看条件为2
file file 白名单模板文件

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

频道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": 400,
    "status": "error",
    "message": "whitelist excel parse error.",
    "data": ""
}

表格记录没有数据

{
    "code": 400,
    "status": "error",
    "message": "whitelist excel no data.",
    "data": ""
}

字段说明

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

php请求示例

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

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

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

// 拼接需要签名的参数
$params["sign"] = $sign;
$url="http://api.polyv.net/live/v3/channel/auth/upload-white-list?".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);
   $file_contents = curl_exec($ch);
   curl_close($ch);
   return $file_contents;
}

// 文件不参与签名
$file['file'] = new CURLFile(realpath("test.xls"));
echo post($url, $file);
?>

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

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

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

设置授权认证URL

接口URL

http://api.polyv.net/live/v3/channel/restrict/update-auth-url

接口说明

1、接口用于设置频道和全局播放限制的授权认证URL,通过是否传channelId进行频道和全局区分
2、接口支持https

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

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

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

频道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 成功时为true,错误时为""

php请求示例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => "填写频道号",
  'url' => "www.baidu.com"
);

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


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

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

根据菜单id修改频道菜单信息

接口URL

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

接口说明

1、获取频道的菜单信息
2、接口支持https协议

支持格式

JSON

请求方式

 Post

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
menuId string 菜单id(互动聊天或咨询提问的菜单ID不允许设置)
appId string 从API设置中获取,在直播系统登记的appId
sign string 签名,为32位大写的MD5值
timestamp string 当前13位毫秒级(兼容10位秒级)时间戳,3分钟内有效
content string 菜单的内容

响应成功JSON示例:

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

响应异常JSON示例:

{
  "code": 403,
  "status": "error",
  "message": "access forbidden",
  "data": ""
}

字段说明

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

状态码以及错误信息说明

code message 说明
200 success 操作成功
403 error access forbidden|访问受限,sign错误,或者无权限操作
400 invalid menu url content 当菜单为推广外链时,content内容为非url格式
400 invalid menu type 当菜单类型为互动聊天和咨询提问时,无法修改菜单内容
400 appId is required. 没有传appId
400 application not found. application找不到
400 invalid timestamp. 时间长过期,30分钟有效
400 update channel menu failed. 系统出错误

php请求示例

<?php

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

//接口需要的参数(非sign)赋值
$menuId = "菜单Id";
$content = "菜单内容";
$timestamp = 1528708015437;//当前时间戳
$appId = "用户的appid";
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法

$post_data = array(
    'appId'=>$appId,
    'timestamp'=>$timestamp,
    'menuId'=>$menuId,
    'content'=>$content,
    'sign'=>$sign
  );

//接口请求url
$url = "http://api.polyv.net/live/v3/channel/menu/update.do";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// post数据
curl_setopt($ch, CURLOPT_POST, 1);
// post的变量
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>

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

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

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

查询频道的菜单信息

接口URL

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

接口说明

1、获取频道的菜单信息
2、接口支持https协议

支持格式

JSON

请求方式

 GET

请求数限制

TRUE

请求参数

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

响应成功JSON示例:

{
  "code": 200,
  "status": "success",
  "message": "",
  "data": [
    {
      "menuId": "521e4f5847",
      "menuType": "desc",
      "name": "直播介绍",
      "ordered": 1,
      "content": ""
    },
    {
      "menuId": "1b01bc166b",
      "menuType": "chat",
      "name": "互动聊天",
      "ordered": 2,
      "content": ""
    },
    {
      "menuId": "41d186c2ab",
      "menuType": "quiz",
      "name": "咨询提问",
      "ordered": 3,
      "content": ""
    },
    {
      "menuId": "c2f9e7d8f4",
      "menuType": "iframe",
      "name": "test",
      "ordered": 4,
      "content": null
    },
    {
      "menuId": "df8a32aaf7",
      "menuType": "text",
      "name": "1212",
      "ordered": 5,
      "content": "<p><br></p>"
    }
  ]
}

响应异常JSON示例:

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

字段说明

字段 说明
menuId 菜单Id
menuType 菜单类型, desc为直播介绍,chat为聊天室,quiz为咨询提问,iframe为推广外链,text为自定义图文菜单
name 菜单名称
ordered 排序
content 内容

php请求示例

<?php

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

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

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

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
//接口请求url
$url = "http://api.polyv.net/live/v3/channel/menu/list.do?appId=$appId&timestamp=$timestamp&channelId=$channelId&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/channel/auth/get

接口说明

1、接口用于获取频道观看条件
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

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

响应成功JSON示例:

带频道ID的查询(频道生效观看条件)

#主要观看条件是无观看条件,次要观看条件是白名单观看条件
{
  "code": 200,
  "status": "success",
  "message": "",
  "data": [
    {
      "channelId": 102666,
      "rank": 1,   //主要观看条件
      "userId": "edvf2fpec9",
      "globalSettingEnabled": "N",
      "enabled": "N",
      "authType": "none"
    },
    {
      "channelId": 102666,
      "rank": 2,   //次要观看条件
      "userId": "edvf2fpec9",
      "globalSettingEnabled": "N",
      "enabled": "N",
      "authType": "phone",
      "authTips": "观看提示哦,大家请注意"
    }
  ]
}

#主要观看条件是验证码观看条件,次要观看条件是付费观看
{
  "code": 200,
  "status": "success",
  "message": "",
  "data": [
    {
      "channelId": 102666,
      "rank": 1,   //主要观看条件
      "userId": "edvf2fpec9",
      "globalSettingEnabled": "N",
      "enabled": "N",
      "authType": "code",
      "authCode": "2194",
      "qcodeTips": "请填写验证码",
      "qcodeImg": "http://www.polyv.net/code.png"
    },
    {
      "channelId": 102666,
      "rank": 2,   //次要观看条件
      "userId": "edvf2fpec9",
      "globalSettingEnabled": "N",
      "enabled": "N",
      "authType": "pay",
      "payAuthTips": "付费可看啦",
      "price": 0.10,
      "watchEndTime": null,
      "validTimePeriod": 100
    }
  ]
}

#主要观看条件是登记观看,次要观看条件是自定义授权观看
{
  "code": 200,
  "status": "success",
  "message": "",
  "data": [
    {
      "channelId": 102666,
      "rank": 1,   //主要观看条件
      "userId": "edvf2fpec9",
      "globalSettingEnabled": "N",
      "enabled": "N",
      "authType": "info"
    },
    {
      "channelId": 102666,
      "rank": 2,   //次要观看条件
      "userId": "edvf2fpec9",
      "globalSettingEnabled": "N",
      "enabled": "N",
      "authType": "custom",
      "customKey": "18c9a2e2a1",
      "customUri": "http://www.polyv.net/custom.htm"
    }
  ]
}

#主要观看条件是外部授权观看,次要观看条件是分享观看
{
  "code": 200,
  "status": "success",
  "message": "",
  "data": [
    {
      "channelId": 102666,
      "rank": 1,   //主要观看条件
      "userId": "edvf2fpec9",
      "globalSettingEnabled": "N",
      "enabled": "N",
      "authType": "external",
      "externalKey": "9828d6d5c7",
      "externalUri": "http://www.polyv.net/externalUri.htm",
      "externalRedirectUri": "http://www.polyv.net/externalRedirectUri.htm"
    },
    {
      "channelId": 102666,
      "rank": 2,   //次要观看条件
      "userId": "edvf2fpec9",
      "globalSettingEnabled": "N",
      "enabled": "N",
      "authType": "wxshare"
    }
  ]
}

不带频道ID的查询(全局观看条件)

{
  "code": 200,
  "status": "success",
  "message": "",
  "data": [
    {
      "userId": "edvf2fpec9",
      "rank": 1,
      "enabled": "N",
      "authType": "none",
      "authTips": "欢迎观看本直播",
      "payAuthTips": "欢迎观看本直播",
      "authCode": null,
      "qcodeTips": null,
      "qcodeImg": null,
      "price": 0.00,
      "watchEndTime": null,
      "validTimePeriod": null,
      "customKey": "a0088ec548",
      "customUri": null,
      "externalKey": "5ca1b8cc31",
      "externalUri": null,
      "externalRedirectUri": null
    },
    {
      "userId": "edvf2fpec9",
      "rank": 2,
      "enabled": "N",
      "authType": "none",
      "authTips": "欢迎观看本直播",
      "payAuthTips": "欢迎观看本直播",
      "authCode": null,
      "qcodeTips": null,
      "qcodeImg": null,
      "price": 0.00,
      "watchEndTime": null,
      "validTimePeriod": null,
      "customKey": "8ad66e747e",
      "customUri": null,
      "externalKey": "9c90190d44",
      "externalUri": null,
      "externalRedirectUri": null
    }
  ]
}

响应失败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 请求成功为数据内容,错误为空串
channelId 频道ID
userId 用户ID
rank 用于实现一个频道设置两个观看条件,为1或2(1为主要条件,2为次要条件)
globalSettingEnabled 是否开启全局设置(Y/N)
enabled 是否开启观看条件(Y/N)
authType 观看条件类型(1. 无限制 none 2. 验证码观看 code 3. 付费观看 pay 4. 白名单观看 phone 5. 登记观看 info 6. 分享观看 wxshare 7. 自定义授权观看 custom 8. 外部授权观看 external)
authTips 白名单观看提示信息
payAuthTips 付费观看提示信息
authCode 验证码观看的验证码
qcodeTips 验证码观看的二维码提示
qcodeImg 验证码观看的二维码图片
price 付费观看的价格
watchEndTime 付费观看,截止时间,为null表示:一次付费,永久有效
validTimePeriod 付费观看的截止时长 (天)
customKey 自定义授权观看的key
customUri 自定义授权观看的接口地址
externalKey 外部授权观看的key
externalUri 外部授权观看的接口地址
externalRedirectUri 外部授权观看,用户直接访问观看页时的跳转地址

php请求示例

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

$channelId="183950";

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

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

$url = "http://api.polyv.net/live/v3/channel/auth/get?appId=".$appId."&channelId=".$channelId."&timestamp=".$timestamp."&sign=".$sign;

echo file_get_contents($url);

?>

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

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

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