视频直播信息提交

接口地址

https://as.dun.163yun.com/v3/livevideo/submit

接口描述

提交视频直播流相关信息接口,信息提交后,易盾会根据客户自己设置的截图频率对直播流进行截图检测,检测结果需产品自行定期调用视频直播结果获取接口获取。

支持格式

检测接口支持的流媒体协议如下:rtp、srtp、rtmp、rtmps、mmsh、mmst、hls、http、tcp、https等。

请求参数

公共参数已省略,详细见 请求公共参数

参数名称类型是否必选最大长度描述
urlStringY512直播流地址
dataIdStringY128直播流唯一标识
versionStringY4接口版本号,可选值 v3
accountLevelStringN10账号级别/主播级别
accountNameStringN30账号名称/主播名称
roomNoStringN20主播房间号
ageStringN64主播年龄
labourUnionStringN256主播所属工会
operationManagerStringN128运营管理者
callbackStringN512数据回调参数,产品根据业务情况自行设计,当获取离线检测结果时,易盾反垃圾云服务会返回该字段
scFrequencyNumberN4截图检测频率,默认5秒截图检测一次,可设置范围为0.5~60秒
callbackUrlStringN256离线结果回调通知到客户的URL。主动回调数据接口超时时间设置为2s,为了保证顺利接收数据,需保证接收接口性能稳定并且保证幂等性。

响应结果

响应字段如下,响应通用字段已省略,详细见 响应通用字段

参数名称类型描述
resultBooleantrue表示提交成功,false表示提交失败

请求示例

/*
 * @(#) LiveVideoCheckAPIDemo.java 2016年8月1日
 *
 * Copyright 2010 NetEase.com, Inc. All rights reserved.
 */
package com.netease.is.antispam.demo.video;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import org.apache.http.Consts;
import org.apache.http.client.HttpClient;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.netease.is.antispam.demo.utils.HttpClient4Utils;
import com.netease.is.antispam.demo.utils.SignatureUtils;

/**
 * 调用易盾反垃圾云服务直播电视墙提交接口API示例,该示例依赖以下jar包:
 * 1. httpclient,用于发送http请求
 * 2. commons-codec,使用md5算法生成签名信息,详细见SignatureUtils.java
 * 3. gson,用于做json解析
 *
 * @author hzgaomin
 * @version 2016年8月1日
 */
public class LiveWallSubmitAPIDemo {
    /**
     * 产品密钥ID,产品标识
     */
    private final static String SECRETID = "your_secret_id";
    /**
     * 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露
     */
    private final static String SECRETKEY = "your_secret_key";
    /**
     * 业务ID,易盾根据产品业务特点分配
     */
    private final static String BUSINESSID = "your_business_id";
    /**
     * 易盾反垃圾云服务直播流信息提交接口地址
     */
    private final static String API_URL = "https://as.dun.163yun.com/v3/livevideo/submit";
    /**
     * 实例化HttpClient,发送http请求使用,可根据需要自行调参
     */
    private static HttpClient httpClient = HttpClient4Utils.createHttpClient(100, 20, 1000, 1000, 1000);

    public static void main(String[] args) throws Exception {
        Map<String, String> params = new HashMap<String, String>();
        // 1.设置公共参数
        params.put("secretId", SECRETID);
        params.put("businessId", BUSINESSID);
        params.put("version", "v3");
        params.put("timestamp", String.valueOf(System.currentTimeMillis()));
        params.put("nonce", String.valueOf(new Random().nextInt()));

        // 2.设置私有参数
        params.put("url", "http://xxx.xxx.com/xxxx");
        params.put("dataId", "fbfcad1c-dba1-490c-b4de-e784c2691765");
        // params.put("callback", "{\"p\":\"xx\"}");
        // params.put("scFrequency", "5");
        // 主动回调地址url,如果设置了则走主动回调逻辑
        // params.put("callbackUrl", "http://***");

        // 3.生成签名信息
        String signature = SignatureUtils.genSignature(SECRETKEY, params);
        params.put("signature", signature);

        // 4.发送HTTP请求,这里使用的是HttpClient工具包,产品可自行选择自己熟悉的工具包发送请求
        String response = HttpClient4Utils.sendPost(httpClient, API_URL, params, Consts.UTF_8);

        // 5.解析接口返回值
        JsonObject jObject = new JsonParser().parse(response).getAsJsonObject();
        int code = jObject.get("code").getAsInt();
        String msg = jObject.get("msg").getAsString();
        if (code == 200) {
            boolean result = jObject.get("result").getAsBoolean();
            if (result) {
                System.out.println("推送成功!");
            } else {
                System.out.println("推送失败!");
            }
        } else {
            System.out.println(String.format("ERROR: code=%s, msg=%s", code, msg));
        }
    }
}

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
易盾反垃圾云服务直播电视墙提交接口python示例代码
接口文档: http://dun.163.com/api.html
python版本:python3.7
运行:
    1. 修改 SECRET_ID,SECRET_KEY,BUSINESS_ID 为对应申请到的值
    2. $ python livewall_submit.py
"""
__author__ = 'yidun-dev'
__date__ = '2019/11/27'
__version__ = '0.2-dev'

import hashlib
import time
import random
import urllib.request as urlrequest
import urllib.parse as urlparse
import json


class LiveWallSubmitAPIDemo(object):
    """直播电视墙提交接口示例代码"""
    API_URL = "https://as.dun.163yun.com/v3/livevideo/submit"
    VERSION = "v3"

    def __init__(self, secret_id, secret_key, business_id):
        """
        Args:
            secret_id (str) 产品密钥ID,产品标识
            secret_key (str) 产品私有密钥,服务端生成签名信息使用
            business_id (str) 业务ID,易盾根据产品业务特点分配
        """
        self.secret_id = secret_id
        self.secret_key = secret_key
        self.business_id = business_id

    def gen_signature(self, params=None):
        """生成签名信息
        Args:
            params (object) 请求参数
        Returns:
            参数签名md5值
        """
        buff = ""
        for k in sorted(params.keys()):
            buff += str(k) + str(params[k])
        buff += self.secret_key
        return hashlib.md5(buff.encode("utf8")).hexdigest()

    def check(self, params):
        """请求易盾接口
        Args:
            params (object) 请求参数
        Returns:
            请求结果,json格式
        """
        params["secretId"] = self.secret_id
        params["businessId"] = self.business_id
        params["version"] = self.VERSION
        params["timestamp"] = int(time.time() * 1000)
        params["nonce"] = int(random.random() * 100000000)
        params["signature"] = self.gen_signature(params)

        try:
            params = urlparse.urlencode(params).encode("utf8")
            request = urlrequest.Request(self.API_URL, params)
            content = urlrequest.urlopen(request, timeout=1).read()
            return json.loads(content)
        except Exception as ex:
            print("调用API接口失败:", str(ex))


if __name__ == "__main__":
    """示例代码入口"""
    SECRET_ID = "your_secret_id"  # 产品密钥ID,产品标识
    SECRET_KEY = "your_secret_key"  # 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露
    BUSINESS_ID = "your_business_id"  # 业务ID,易盾根据产品业务特点分配
    api = LiveWallSubmitAPIDemo(SECRET_ID, SECRET_KEY, BUSINESS_ID)

    # 私有请求参数
    params = {
        "dataId": "fbfcad1c-dba1-490c-b4de-e784c2691765",
        "url": "http://xxx.xxx.com/xxxx"
        # "callback": "{\"p\":\"xx\"}"
        # "scFrequency": 5
        # "callbackUrl": "http://***"  # 主动回调地址url,如果设置了则走主动回调逻辑
    }

    ret = api.check(params)

    code: int = ret["code"]
    msg: str = ret["msg"]
    if code == 200:
        result: bool = ret["result"]
        if result:
            print("推送成功!")
        else:
            print("推送失败!")
    else:
        print("ERROR: code=%s, msg=%s" % (ret["code"], ret["msg"]))
<?php
/** 直播电视墙提交检测接口 */
/** 产品密钥ID,产品标识 */
define("SECRETID", "your_secret_id");
/** 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露 */
define("SECRETKEY", "your_secret_key");
/** 业务ID,易盾根据产品业务特点分配 */
define("BUSINESSID", "your_business_id");
/** 易盾反垃圾云服务直播电视墙检测接口地址 */
define("API_URL", "https://as.dun.163yun.com/v3/livevideo/submit");
/** api version */
define("VERSION", "v3");
/** API timeout*/
define("API_TIMEOUT", 1);
/** php内部使用的字符串编码 */
define("INTERNAL_STRING_CHARSET", "auto");
/**
 * 计算参数签名
 * $params 请求参数
 * $secretKey secretKey
 */
function gen_signature($secretKey, $params){
	ksort($params);
	$buff="";
	foreach($params as $key=>$value){
	     if($value !== null) {
	        $buff .=$key;
		$buff .=$value;
    	     }
	}
	$buff .= $secretKey;
	return md5($buff);
}
/**
 * 将输入数据的编码统一转换成utf8
 * @params 输入的参数
 */
function toUtf8($params){
	$utf8s = array();
    foreach ($params as $key => $value) {
    	$utf8s[$key] = is_string($value) ? mb_convert_encoding($value, "utf8", INTERNAL_STRING_CHARSET) : $value;
    }
    return $utf8s;
}
/**
 * 反垃圾请求接口简单封装
 * $params 请求参数
 */
function check($params){
	$params["secretId"] = SECRETID;
	$params["businessId"] = BUSINESSID;
	$params["version"] = VERSION;
	$params["timestamp"] = time() * 1000;// time in milliseconds
	$params["nonce"] = sprintf("%d", rand()); // random int
	$params = toUtf8($params);
	$params["signature"] = gen_signature(SECRETKEY, $params);
	// var_dump($params);
	$options = array(
	    'http' => array(
	        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
	        'method'  => 'POST',
	        'timeout' => API_TIMEOUT, // read timeout in seconds
	        'content' => http_build_query($params),
	    ),
	);
	$context  = stream_context_create($options);
	$result = file_get_contents(API_URL, false, $context);
	if($result === FALSE){
		return array("code"=>500, "msg"=>"file_get_contents failed.");
	}else{
		return json_decode($result, true);	
	}
}
// 简单测试
function main(){
    echo "mb_internal_encoding=".mb_internal_encoding()."\n";
	$params = array(
		"dataId"=>"fbfcad1c-dba1-490c-b4de-e784c2691765",
		"url"=>"http://xxx.xxx.com/xxxx"
		// "callback"=>"{\"p\":\"xx\"}",
	);
	$ret = check($params);
	var_dump($ret);
	if ($ret["code"] == 200) {
		$result = $ret["result"];
		// status 0:成功,1:失败
		$status = $result["status"];
        $taskId = $result["taskId"];
        if ($status == 0) {
            echo "提交成功,taskId={$taskId}";
        } else {
            echo "提交失败,taskId={$taskId}";
        }
    }else{
    	var_dump($ret);
    }
}
main();
?>
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Net.Http;

namespace Com.Netease.Is.Antispam.Demo
{
    class LiveVideoSubmitApiDemo
    {

        public static void liveVideoSubmit()
        {
            /** 产品密钥ID,产品标识 */
            String secretId = "your_secret_id";
            /** 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露 */
            String secretKey = "your_secret_key";
            /** 业务ID,易盾根据产品业务特点分配 */
            String businessId = "your_business_id";
            /** 易盾反垃圾云服务视频直播信息提交接口地址  */
            String apiUrl = "https://as.dun.163yun.com/v3/livevideo/submit";
            Dictionary<String, String> parameters = new Dictionary<String, String>();

            long curr = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
            String time = curr.ToString();

            // 1.设置公共参数
            parameters.Add("secretId", secretId);
            parameters.Add("businessId", businessId);
            parameters.Add("version", "v3");
            parameters.Add("timestamp", time);
            parameters.Add("nonce", new Random().Next().ToString());

            // 2.设置私有参数
            parameters.Add("url", "http://xxx.xxx.com/xxxx");
            parameters.Add("dataId", "fbfcad1c-dba1-490c-b4de-e784c2691765");
            // parameters.Add("callback", "{\"p\":\"xx\"}");
            // parameters.Add("scFrequency", "5");

            // 3.生成签名信息
            String signature = Utils.genSignature(secretKey, parameters);
            parameters.Add("signature", signature);

            // 4.发送HTTP请求
            HttpClient client = Utils.makeHttpClient();
            String result = Utils.doPost(client, apiUrl, parameters, 1000);
            if(result != null)
            {
                JObject ret = JObject.Parse(result);
                int code = ret.GetValue("code").ToObject<Int32>();
                String msg = ret.GetValue("msg").ToObject<String>();
                if (code == 200)
                {
                    Boolean re = ret.GetValue("result").ToObject<Boolean>();
                    if(re == true)
                    {
                        Console.WriteLine("推送成功!");
                    }
                    else
                    {
                        Console.WriteLine("推送失败!");
                    }

                }
                else
                {
                    Console.WriteLine(String.Format("ERROR: code={0}, msg={1}", code, msg));
                }
            }
            else
            {
                Console.WriteLine("Request failed!");
            }

        }
    }
}
var utils=require("./utils");

//产品密钥ID,产品标识 
var secretId="your_secret_id";
// 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露 
var secretKey="your_secret_key";
// 业务ID,易盾根据产品业务特点分配 
var businessId="your_business_id";
// 易盾反垃圾云服务直播电视墙流信息提交接口地址
var apiurl="https://as.dun.163yun.com/v3/livevideo/submit";
//请求参数
var post_data = {
	// 1.设置公有有参数
	secretId:secretId,
	businessId:businessId,
	version:"v3",
	timestamp:new Date().getTime(),
	nonce:utils.noncer(),
	// 2.设置私有参数
	dataId:"myid",
	url:"www.xxxx.com/xxx"
	// callback:"mycallback",
	// scFrequency:5
};
var signature=utils.genSignature(secretKey,post_data);
post_data.signature=signature;
//http请求结果
var responseCallback=function(responseData){
	var data = JSON.parse(responseData);
	var code=data.code;
	var msg=data.msg;
	if(code==200){
		var result=data.result;
		if(result){
			console.log("推送成功");
		}else{
			console.log("推送失败");
		}
	}else{
		 console.log('ERROR:code=' + code+',msg='+msg);
	}
   
}
utils.sendHttpRequest(apiurl,"POST",post_data,responseCallback);
/*
@Author : yidun_dev
@Date : 2020-01-20
@File : livewall_submit.go
@Version : 1.0
@Golang : 1.13.5
@Doc : http://dun.163.com/api.html
*/
package main

import (
	"crypto/md5"
	"encoding/hex"
	"encoding/json"
	"fmt"
	simplejson "github.com/bitly/go-simplejson"
	"io/ioutil"
	"math/rand"
	"net/http"
	"net/url"
	"sort"
	"strconv"
	"strings"
	"time"
)

const (
	apiUrl     = "https://as.dun.163yun.com/v3/livevideo/submit"
	version    = "v3"
	secretId   = "your_secret_id"   //产品密钥ID,产品标识
	secretKey  = "your_secret_key"  //产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露
	businessId = "your_business_id" //业务ID,易盾根据产品业务特点分配
)

//请求易盾接口
func check(params url.Values) *simplejson.Json {
	params["secretId"] = []string{secretId}
	params["businessId"] = []string{businessId}
	params["version"] = []string{version}
	params["timestamp"] = []string{strconv.FormatInt(time.Now().UnixNano()/1000000, 10)}
	params["nonce"] = []string{strconv.FormatInt(rand.New(rand.NewSource(time.Now().UnixNano())).Int63n(10000000000), 10)}
	params["signature"] = []string{genSignature(params)}

	resp, err := http.Post(apiUrl, "application/x-www-form-urlencoded", strings.NewReader(params.Encode()))

	if err != nil {
		fmt.Println("调用API接口失败:", err)
		return nil
	}

	defer resp.Body.Close()

	contents, _ := ioutil.ReadAll(resp.Body)
	result, _ := simplejson.NewJson(contents)
	return result
}

//生成签名信息
func genSignature(params url.Values) string {
	var paramStr string
	keys := make([]string, 0, len(params))
	for k := range params {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	for _, key := range keys {
		paramStr += key + params[key][0]
	}
	paramStr += secretKey
	md5Reader := md5.New()
	md5Reader.Write([]byte(paramStr))
	return hex.EncodeToString(md5Reader.Sum(nil))
}

func main() {
	params := url.Values{
		"dataId": []string{"fbfcad1c-dba1-490c-b4de-e784c2691765"},
		"url":    []string{"http://xxx.xxx.com/xxxx"},
		//"callback": []string{"{\"p\":\"xx\"}"},
		//"scFrequency": []string{"5"},
		//"callbackUrl": []string{"http://***"},  //主动回调地址url,如果设置了则走主动回调逻辑
	}
	ret := check(params)

	code, _ := ret.Get("code").Int()
	message, _ := ret.Get("msg").String()
	if code == 200 {
		result, _ := ret.Get("result").Map()
		status, _ := result["status"].(json.Number).Int64()
		taskId := result["taskId"].(string)
		if status == 0 {
			fmt.Printf("提交成功!, taskId: %s", taskId)
		} else {
			fmt.Printf("提交失败!")
		}
	} else {
		fmt.Printf("ERROR: code=%d, msg=%s", code, message)
	}
}

响应示例

输出结果:

{
    "code": 200,
    "msg": "ok",
    "result": true
}
QQ咨询:反馈更及时 在线咨询 电话咨询:95163223