视频直播检测结果获取
2020.04.01 19:18:59
接口地址
https://api.aq.163.com/v2/livewall/callback/results
接口描述
该接口用于获取直播墙审核结果,结果包含截图证据信息及违规分类信息等。
接口请求频率
小于10s/20次,请求频率过快服务器会拒绝处理。
请求参数
该接口参数与请求公共参数一致,详细见 请求公共参数
响应结果
响应字段如下,响应通用字段已省略,详细见 响应通用字段 :
参数名称 | 类型 | 描述 |
---|---|---|
result | json数组 | 检测结果数组 |
result 数据结构
参数名称 | 类型 | 描述 |
---|---|---|
callback | String | 产品提交直播流信息时带的 callback 字段数据,用于标识直播流,产品根据业务情况自行设计 |
taskId | String | 音视频数据请求标识,可以根据该标识查询视频数据最新结果 |
status | Number | 检测状态,101为检测中,102为检测结束 |
action | Number | 审核操作, 1为忽略,2为警告,3为断流,4为提示,10为机器检测结束 |
actionTime | Number | 操作时间,UNIX_TIME时间戳,毫秒为单位 |
label | Number | 违规类型,100-色情,111-淫秽表演,112-偶然走光,113-服装暴露,114-床上直播,115-音乐内容低俗,116-言论低俗涉黄,117-违规服装,118-上装暴露,119-下装暴露,120-低俗连麦,123-字幕低俗,124-出现不雅物品,125-低俗妆容,126-传播色情,涉黄200-广告,210-二维码,211-商业推广,212-提及竞品,213-字幕推广,214-竞品标识,215-竞品播放器,300-暴恐,311恐怖主义,312-暴力血腥,400-违禁,411-危险表演,412-涉毒/赌/传销,413-违禁服装,414-监管类违禁游戏,415-赌博游戏,416-赌博信息,500-涉政,511-影响政府形象,512-邪教迷信,513-涉军事,514涉宗教,517-涉及政治敏感话题,518-出现国旗国徽,519-出现领导人画像,800-不文明,811-赤膊,812-性感,821-涉酒,822-涉烟,823-纹身,824-未成年,825-危险驾驶,826-传播负面情绪,1000-其他,1020-黑屏,1022-画质差,1023-无营养,1024-盗播版权内容,1025-无音乐设备,1026-与音乐无关,1028-无版权游戏,1029-非普通话直播,1030-挂机,1031-私密场所直播,1032-卡顿,1050-自定义 |
detail | String | 违规详细说明 |
warnCount | Number | 警告次数 |
evidence | json对象 | 证据信息,详细结构如下 |
evidence数据结构:
参数名称 | 类型 | 描述 |
---|---|---|
snapshot | String | 证据截图url |
请求示例
/*
* @(#) LiveVideoCallbackAPIDemo.java 2016年8月1日
*
* Copyright 2010 NetEase.com, Inc. All rights reserved.
*/
package com.netease.is.antispam.demo.v2;
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.JsonArray;
import com.google.gson.JsonElement;
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 LiveVideoCallbackAPIDemo {
/** 产品密钥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://api.aq.163.com/v2/livewall/callback/results";
/** 实例化HttpClient,发送http请求使用,可根据需要自行调参 */
private static HttpClient httpClient = HttpClient4Utils.createHttpClient(100, 20, 10000, 1000, 1000);
/**
*
* @param args
* @throws Exception
*/
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", "v2");
params.put("timestamp", String.valueOf(System.currentTimeMillis()));
params.put("nonce", String.valueOf(new Random().nextInt()));
// 2.生成签名信息
String signature = SignatureUtils.genSignature(SECRETKEY, params);
params.put("signature", signature);
// 3.发送HTTP请求,这里使用的是HttpClient工具包,产品可自行选择自己熟悉的工具包发送请求
String response = HttpClient4Utils.sendPost(httpClient, API_URL, params, Consts.UTF_8);
// 4.解析接口返回值
JsonObject resultObject = new JsonParser().parse(response).getAsJsonObject();
int code = resultObject.get("code").getAsInt();
String msg = resultObject.get("msg").getAsString();
if (code == 200) {
JsonArray resultArray = resultObject.getAsJsonArray("result");
for (JsonElement jsonElement : resultArray) {
JsonObject jObject = jsonElement.getAsJsonObject();
String callback = jObject.get("callback").getAsString();
int action = jObject.get("action").getAsInt();
int label = jObject.get("label").getAsInt();
int warnCount = jObject.get("warnCount").getAsInt();
JsonArray evidenceObjec = jObject.get("evidence").getAsJsonArray();
if (action == 2) {// 警告
System.out.println(String.format("警告, callback=%s, 总警告次数:%s, 证据信息:%s", callback, warnCount, evidenceObjec));
} else if (action == 3) { // 断流
System.out.println(String.format("断流, callback=%s, 总警告次数:%s, 证据信息:%s", callback, warnCount, evidenceObjec));
}
}
} 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_callback.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 LiveWallCallbackAPIDemo(object):
"""直播电视墙离线结果获取接口示例代码"""
API_URL = "https://as.dun.163yun.com/v2/livewall/callback/results"
VERSION = "v2"
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):
"""请求易盾接口
Returns:
请求结果,json格式
"""
params = {}
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=10).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" # 产品私有密list钥,服务端生成签名信息使用,请严格保管,避免泄露
BUSINESS_ID = "your_business_id" # 业务ID,易盾根据产品业务特点分配
api = LiveWallCallbackAPIDemo(SECRET_ID, SECRET_KEY, BUSINESS_ID)
ret = api.check()
code: int = ret["code"]
msg: str = ret["msg"]
if code == 200:
resultArray: list = ret["result"]
for result in resultArray:
taskId: str = result["taskId"]
status: int = result["status"]
callback: str = result["callback"]
action: int = result["action"]
actionTime: int = result["actionTime"]
label: int = result["label"]
detail: str = result["detail"]
warnCount: int = result["warnCount"]
evidence: dict = result["evidence"]
if action == 2: # 警告
print("警告, taskId: %s, callback: %s, 总警告次数: %s, 证据信息: %s" % (taskId, callback, warnCount, evidence))
elif action == 3: # 断流
print("断流, taskId: %s, callback: %s, 总警告次数: %s, 证据信息: %s" % (taskId, callback, warnCount, evidence))
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://api.aq.163.com/v2/livewall/callback/results");
/** api version */
define("VERSION", "v2");
/** API timeout*/
define("API_TIMEOUT", 10);
/** 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 = array();
$params["secretId"] = SECRETID;
$params["businessId"] = BUSINESSID;
$params["version"] = VERSION;
$params["timestamp"] = sprintf("%d", round(microtime(true)*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),
),
);
var_dump($params);
$context = stream_context_create($options);
$result = file_get_contents(API_URL, false, $context);
return json_decode($result, true);
}
// 简单测试
function main(){
echo "mb_internal_encoding=".mb_internal_encoding()."\n";
$ret = check();
var_dump($ret);
if ($ret["code"] == 200) {
$result = $ret["result"];
foreach($result as $index => $value){
$action = $value["action"];
if($action == 2){// 警告
echo "警告,callback = ".$value["callback"].", warnCount = ".$value["warnCount"].", label = ".$value["label"].", evidence = ".json_encode($value["evidence"])."\n";
} else if($action == 3) { // 断流
echo "断流,callback = ".$value["callback"].", warnCount = ".$value["warnCount"].", label = ".$value["label"].", evidence = ".json_encode($value["evidence"])."\n";
}
}
}else{
// error handler
}
}
main();
?>
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Net.Http;
namespace Com.Netease.Is.Antispam.Demo
{
class LiveVideoCallbackApiDemo
{
public static void liveVideotCallBack()
{
/** 产品密钥ID,产品标识 */
String secretId = "your_secret_id";
/** 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露 */
String secretKey = "your_secret_key";
/** 业务ID,易盾根据产品业务特点分配 */
String businessId = "your_business_id";
/** 易盾反垃圾云服务视频直播检测结果获取接口地址 */
String apiUrl = "https://api.aq.163.com/v2/livewall/callback/results";
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", "v2");
parameters.Add("timestamp", time);
parameters.Add("nonce", new Random().Next().ToString());
// 2.生成签名信息
String signature = Utils.genSignature(secretKey, parameters);
parameters.Add("signature", signature);
// 3.发送HTTP请求
HttpClient client = Utils.makeHttpClient();
String result = Utils.doPost(client, apiUrl, parameters, 10000);
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)
{
JArray array = (JArray)ret.SelectToken("result");
foreach (var item in array)
{
JObject tmp = (JObject)item;
String callback = tmp.GetValue("callback").ToObject<String>();
JObject evidenceObjec = (JObject)tmp.SelectToken("evidence");
int action = tmp.GetValue("action").ToObject<Int32>();
int label = tmp.GetValue("label").ToObject<Int32>();
int warnCount = tmp.GetValue("warnCount").ToObject<Int32>();
if (action == 2) {
Console.WriteLine(String.Format("警告, label={0}, warnCount={1}, evidence={2}", label, warnCount, evidenceObject.ToString()));
} else if (action == 3)
{
Console.WriteLine(String.Format("断流, label={0}, warnCount={1}, evidence={2}", label, warnCount, evidenceObject.ToString()));
}
}
}
else
{
Console.WriteLine(String.Format("ERROR: code={0}, msg={1}", code, msg));
}
}
else
{
Console.WriteLine("Request failed!");
}
}
}
}
/**
* 易盾工具集合,包含:
* 1:noncer 产生随机整数
* 2:genSignature 生成Md5签名
* 3:sendHttpRequest 发送http请求
*/
var utils=(function(){
var http = require('https');
var urlutil=require('url');
var querystring = require('querystring');
var crypto = require('crypto');
//产生随机整数--工具方法
var noncer=function(){
var range=function(start,end){
var array=[];
for(var i=start;i<end;++i){
array.push(i);
}
return array;
};
var nonce = range(0,6).map(function(x){
return Math.floor(Math.random()*10);
}).join('');
return nonce;
};
//生成签名算法--工具方法
var genSignature=function(secretKey,paramsJson){
var sorter=function(paramsJson){
var sortedJson={};
var sortedKeys=Object.keys(paramsJson).sort();
for(var i=0;i<sortedKeys.length;i++){
sortedJson[sortedKeys[i]] = paramsJson[sortedKeys[i]]
}
return sortedJson;
}
var sortedParam=sorter(paramsJson);
var needSignatureStr="";
for(var key in sortedParam){
var value=sortedParam[key];
needSignatureStr=needSignatureStr+key+value;
}
needSignatureStr+=secretKey;
var md5er = crypto.createHash('md5');//MD5加密工具
md5er.update(needSignatureStr,"UTF-8");
return md5er.digest('hex');
};
//发送post请求
var sendHttpRequest=function(url,type,data,callback){
var content = querystring.stringify(data,null,null,null);
var urlObj=urlutil.parse(url);
var host=urlObj.hostname;
var path=urlObj.path;
var port=urlObj.port;
var options = {
hostname: host,
port: port,
path: path,
method: type,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Content-Length': Buffer.byteLength(content)
}
};
var responseData="";
var req = http.request(options, function (res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
responseData+=chunk;
});
res.on('end', function () {
callback(responseData);
});
//设置超时
req.setTimeout(1000,function(){
console.log('request timeout!');
req.abort();
});
req.on('error', function (e) {
console.log('request ERROR: ' + e.message);
});
});
req.write(content);
req.end();
};
return {
noncer:noncer,
genSignature:genSignature,
sendHttpRequest:sendHttpRequest
}
})();
//产品密钥ID,产品标识
var secretId="your_secret_id";
// 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露
var secretKey="your_secret_key";
// 业务ID,易盾根据产品业务特点分配
var businessId="your_business_id";
// 易盾反垃圾云服务视频直播检测结果获取接口地址
var apiurl="https://api.aq.163.com/v2/livewall/callback/results";
//请求参数
var post_data = {
// 1.设置公有有参数
secretId:secretId,
businessId:businessId,
version:"v2",
timestamp:new Date().getTime(),
nonce:utils.noncer()
};
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.length==0){
console.log("无数据");
}else{
for(var i=0;i<result.length;i++){
var obj=result[i];
var callback=obj.callback;
var evidence=obj.evidence;
var label=obj.label;
var action = obj.action;
var warnCount = obj.warnCount;
if(action == 2){ // 警告处理
console.log("警告,callback:"+callback+",label:" + label +",warnCount:" + warnCount + ",证据信息:"+JSON.stringify(evidence));
}else if(action == 3){ // 断流处理
console.log("断流,callback:"+callback+",label:" + label +",warnCount:" + warnCount + ",证据信息:"+JSON.stringify(evidence));
}
}
}
}else{
console.log('ERROR:code=' + code+',msg='+msg);
}
}
utils.sendHttpRequest(apiurl,"POST",post_data,responseCallback);
/*
@Author : yidun_dev
@Date : 2020-01-20
@File : livewall_callback.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/v2/livewall/callback/results"
version = "v2"
secretId = "your_secret_id" //产品密钥ID,产品标识
secretKey = "your_secret_key" //产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露
businessId = "your_business_id" //业务ID,易盾根据产品业务特点分配
)
//请求易盾接口
func check() *simplejson.Json {
params := url.Values{}
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() {
ret := check()
code, _ := ret.Get("code").Int()
message, _ := ret.Get("msg").String()
if code == 200 {
resultArray, _ := ret.Get("result").Array()
for _, result := range resultArray {
if resultMap, ok := result.(map[string]interface{}); ok {
taskId := resultMap["taskId"].(string)
callback := resultMap["callback"].(string)
action, _ := resultMap["action"].(json.Number).Int64()
warnCount, _ := resultMap["warnCount"].(json.Number).Int64()
evidence := resultMap["evidence"].(map[string]interface{})
//status, _ := resultMap["status"].(json.Number).Int64()
//actionTime, _ := resultMap["actionTime"].(json.Number).Int64()
//label, _ := resultMap["label"].(json.Number).Int64()
//detail := resultMap["detail"].(string)
if action == 2 { //警告
fmt.Printf("警告, taskId: %s, callback: %s, 总警告次数: %d, 证据信息: %s", taskId, callback, warnCount, evidence)
} else if action == 3 { //断流
fmt.Printf("断流, taskId: %s, callback: %s, 总警告次数: %d, 证据信息: %s", taskId, callback, warnCount, evidence)
}
}
}
} else {
fmt.Printf("ERROR: code=%d, msg=%s", code, message)
}
}
响应示例
输出结果:
{
"code": 200,
"msg": "ok",
"result": [
{
"callback": "40d7e2fba1894512902e92928540a647",
"action": 2,
"actionTime": xxxx,
"label": 100,
"detail": "xxxx",
"warnCount": 1,
"evidence": [
{
"snapshot": "http://xxx.nos.netease.com/xxx.jpeg"
},
{
"snapshot": "http://xxx.nos.netease.com/xxx.jpeg"
}
]
},
{
"callback": "3127e2fba1894512902e92928540a647",
"action": 2,
"actionTime": xxxx,
"label": 100,
"detail": "xxxx",
"warnCount": 1,
"evidence": [
{
"snapshot": "http://xxx.nos.netease.com/xxx.jpeg"
},
{
"snapshot": "http://xxx.nos.netease.com/xxx.jpeg"
}
]
}
]
}