点播检测结果获取接口

接口地址

https://as.dun.163yun.com/v3/video/callback/results

接口描述

该接口用于获取点播视频检测结果,检测结果包含截图证据信息及违规分类信息等。

接口请求频率

小于10s/20次,请求频率过快服务器会拒绝处理。

请求参数

该接口参数与请求公共参数一致,详细见 请求公共参数

响应结果

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

参数名称类型描述
resultjson数组检测结果数组

result 数据结构

参数名称类型描述
statusNumber视频处理状态码,定义为:0:检测成功,120:参数错误,130:解析错误,140:数据类型错误,160:视频大小超限(>5G)
taskIdString音视频数据请求标识,可以根据该标识查询视频数据最新结果
callbackString产品提交视频点播信息时带的 callback 字段数据,用于标识视频,产品根据业务情况自行设计
levelNumber视频级别信息,分为0:正常,1:不确定,2:确定,其中不确定的建议人工复审
evidencesjson对象数组证据信息数组,如果数组为空,则表示该视频为正常视频

evidences对象数据结构:

证据时间戳说明

◆ 证据信息命中黑屏挂机后,type为视频,开始时间和结束时间为证据采集时对应视频内截取第一帧的相对时间。其他垃圾类别,证据开始时间与结束时间一致

参数名称类型描述
beginTimeNumber证据开始相对时间,单位为毫秒,调用方获取后可自行格式化为可视化时间,如:149000 转换为"00:02:29"
endTimeNumber证据结束相对时间,单位为毫秒,调用方获取后可自行格式化为可视化时间,如:149000 转换为"00:02:29"
typeNumber1:图片,2:视频
urlString证据信息
labelsjson对象数组证据结果数组

labels对象数据结构

参数名称类型描述
labelNumber分类信息,100:色情,110:性感;200:广告,210:二维码;300:暴恐,400:违禁,500:涉政,1020:黑屏,1030:挂机
subLabelsjson数组细分类信息,可能包含多个,可能为空
levelNumber级别信息,分为1:不确定,2:确定
rateNumber分数

subLabels 数据结构

参数名称类型描述
subLabelNumber细分类,详细编码请参考下方对应细分类编码对照表
rateNumber置信度分数,0-1之间取值,1为置信度最高,0为置信度最低
detailsjson数组htiInfos:命中详细信息

细分类编码对应表

返回编码字符描述hitInfos
10000PORN_COMMON色情若命中图片中文字检测策略,可返回文字线索信息
10001PORN_VAGINA女下体-
10002PORN_NIPPLE女胸-
10003PORN_PENNIS男下体-
10004PORN_SEXUAL性行为-
10005PORN_HIP臀部-
10006PORN_BLOWJOB口交-
10007PORN_CARTOON卡通色情-
10008PORN_FACE色情人物人物名
10009CHILD_PORN儿童色情-
11000SEXY_COMMON性感低俗-
11001SEXY_KISS亲吻-
20000AD_COMMON广告若命中图片中文字检测策略,可返回文字线索信息
21000QRCODE_COMMON二维码若命中图片中文字检测策略,可返回文字线索信息
30000TERRORISM_COMMON暴恐若命中图片中文字检测策略,可返回文字线索信息
30001TERRORISM_GALLERY暴恐图集-
30002TERRORISM_FLAG暴恐旗帜旗帜名
30003TERRORISM_FACE暴恐人物人物名
30004TERRORISM_LOGO暴恐标识标识名
30005TERRORISM_SCENE暴恐场景场景名
40000CONTRABAND_COMMON违禁若命中图片中文字检测策略,可返回文字线索信息
40001CONTRABAND_GALLERY违禁图集-
40002CONTRABAND_GOOD违禁品违禁品名
40003CONTRABAND_LOGO特殊标识标识名
40004CONTRABAND_BLOOD血腥模型-
40005CONTRABAND_OFFICE_DRESS公职服饰服饰名
40006CONTRABAND_INCIVILIZATION不文明不文明行为
40007CONTRABAND_FACE违禁人物人物名
40008CONTRABAND_SCENE违禁场景场景名
40009CONTRABAND_FIRE火焰-
40010CONTRABAND_SKULL骷髅-
40011CONTRABAND_CURRENCY货币-
50000POLITICS_COMMON涉政若命中图片中文字检测策略,可返回文字线索信息
50001POLITICS_GALLERY涉政图集-
50002POLITICS_MAP_OF_CHINA中国地图-
50003POLITICS_LEADERPIC涉政人物人物名
50004POLITICS_FLAG涉政旗帜旗帜名
50005POLITICS_LOGO涉政标识标识名
50006POLITICS_SCENE涉政场景场景名

请求示例

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

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 hzdingyong
 * @version 2016年8月23日
 */
public class VideoCallbackAPIDemo {
    /** 产品密钥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/video/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", "v3");
        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");
            if (resultArray.size() == 0) {
                System.out.println("暂无回调数据");
            } else {
                for (JsonElement jsonElement : resultArray) {
                    JsonObject jObject = jsonElement.getAsJsonObject();
                    int status = jObject.get("status").getAsInt();
                    if(status!=0){//异常,异常码定义见官网文档
                        System.out.println("视频异常,status="+status);
                        continue;
                    }
                    String callback = jObject.get("callback").getAsString();
                    int videoLevel = jObject.get("level").getAsInt();
                    if (videoLevel == 0) {
                        System.out.println(String.format("正常, callback=%s", callback));
                    } else if (videoLevel == 1 || videoLevel == 2) {
                        JsonArray evidenceArray = jObject.get("evidences").getAsJsonArray();
                        for (JsonElement evidenceElement : evidenceArray) {
                            JsonObject eObject = evidenceElement.getAsJsonObject();
                            long beginTime = eObject.get("beginTime").getAsLong();
                            long endTime = eObject.get("endTime").getAsLong();
                            int type = eObject.get("type").getAsInt();
                            String url = eObject.get("url").getAsString();

                            JsonArray labelArray = eObject.get("labels").getAsJsonArray();
                            for (JsonElement labelElement : labelArray) {
                                JsonObject lObject = labelElement.getAsJsonObject();
                                int label = lObject.get("label").getAsInt();
                                int level = lObject.get("level").getAsInt();
                                double rate = lObject.get("rate").getAsDouble();
                            }
                            System.out.println(String.format("%s, callback=%s, 证据信息:%s, 证据分类:%s, ", videoLevel == 1 ? "不确定"
                                            : "确定", callback, eObject, labelArray));
                        }
                    }
                }
            }
        } 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 video_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 VideoCallbackAPIDemo(object):
    """视频点播离线结果获取接口示例代码"""

    API_URL = "https://as.dun.163yun.com/v3/video/callback/results"
    VERSION = "v3.1"

    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()
            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"  # 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露
    BUSINESS_ID = "your_business_id"  # 业务ID,易盾根据产品业务特点分配
    api = VideoCallbackAPIDemo(SECRET_ID, SECRET_KEY, BUSINESS_ID)
    
    ret = api.check()

    code: int = ret["code"]
    msg: str = ret["msg"]
    if code == 200:
        resultArray: list = ret["result"]
        if len(resultArray) == 0:
            print("暂无回调数据")
        else:
            for result in resultArray:
                status: int = result["status"]
                if status != 0:  # 异常,异常码定义见官网文档
                    print("视频异常, status: %s" % status)
                    continue
                taskId: str = result["taskId"]
                callback: str = result["callback"]
                videoLevel: str = result["level"]
                if videoLevel == 0:
                    print("视频正常, taskId: %s, callback: %s" % (taskId, callback))
                elif videoLevel == 1 or videoLevel == 2:
                    evidenceArray: list = result["evidences"]
                    for evidence in evidenceArray:
                        beginTime: int = evidence["beginTime"]
                        endTime: int = evidence["endTime"]
                        type: int = evidence["type"]
                        url: str = evidence["url"]
                        labelArray: list = evidence["labels"]
                        for labelItem in labelArray:
                            label: int = labelItem["label"]
                            level: int = labelItem["level"]
                            rate: float = labelItem["rate"]
                        print("taskId: %s, %s, callback: %s, 证据信息: %s, 证据分类: %s" %
                              (taskId, "不确定" if videoLevel == 1 else "确定", callback, evidence, labelArray))
    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/video/callback/results");
/** api version */
define("VERSION", "v3");
/** 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);
    // var_dump($result);
    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";
    $ret = check();
    var_dump($ret);
    if ($ret["code"] == 200) {
        $result_array = $ret["result"];
        foreach($result_array as $res_index => $result){
            $status = $result["status"];
    	    if($status!=0){
    	        echo "视频异常,status=".$status;
    		    continue;
            }
            $level = $result["level"];
            if($level != 0){ // 返回 level == 0表示正常
                // 从evidences里获取证据信息,详细说明见http://dun.163.com/support/api#API_13
                foreach ($result['evidences'] as $evi_index => $evidence) {
                    echo json_encode($evidence)."\n";
                }
            }
        }
    }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 VideoCallbackApiDemo
    {
        public static void videoCallBack()
        {
            /** 产品密钥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/video/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", "v3");
            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;
                        int status = tmp.GetValue("status").ToObject<Int32>();
                        if(status!=0){//异常,异常码定义见官网文档
                            Console.WriteLine("视频异常,status="+status);
                            continue;
                        }
                        String callback = tmp.GetValue("callback").ToObject<String>();
                        int videoLevel = tmp.GetValue("level").ToObject<Int32>();
                        if(videoLevel !=0)
                        {
                            JArray evidences = (JArray)tmp.SelectToken("evidences");
                            foreach  (var evidence in evidences)
                            {
                                Console.WriteLine(evidence.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://as.dun.163yun.com/v3/video/callback/results";

//请求参数
var post_data = {
    // 1.设置公有有参数
    secretId:secretId,
    businessId:businessId,
    version:"v3",
    timestamp:new Date().getTime(),
    nonce:utils.noncer()
};
var signature=utils.genSignature(secretKey,post_data);
post_data.signature=signature;
//http请求结果
var responseCallback=function(responseData){
    console.log(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 status = obj.status;
                if(status != 0){//异常,异常码定义见官网文档
                    console.log("视频异常,status="+status);
                    continue;
                }
                var videoLevel=obj.level;
                var callback=obj.callback;
                if(videoLevel==0){
                    console.log("正常,callback:"+callback);
                }else if(videoLevel==1 || videoLevel==2){
                    var evidences=obj.evidences;
                    for(var j=0;j<evidences.length;j++){
                        var evidence=evidences[j];
                        var beginTime=evidence.beginTime;
                        var endTime=evidence.endTime;
                        var type=evidence.type;
                        var url=evidence.url;
                        var labelsArray=evidence.labels;
                        for(var k=0;k<labelsArray.length;k++){
                            var labelObj=labelsArray[k];
                            var label=labelObj.label;
                            var level=labelObj.level;
                            var rate=labelObj.rate;
                        }
                        var resultText=videoLevel==1?"不确定":"确定";
                        console.log(resultText+",callback:"+callback+",证据分类:"+JSON.stringify(labelsArray)+",证据信息:"+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 : video_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/v3/video/callback/results"
	version    = "v3.1"
	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()
		if len(resultArray) == 0 {
			fmt.Printf("暂无回调数据")
		} else {
			for _, result := range resultArray {
				if resultMap, ok := result.(map[string]interface{}); ok {
					status, _ := resultMap["status"].(json.Number).Int64()
					if status != 0 {
						fmt.Printf("视频异常, status: %d", status)
						continue
					}
					taskId, _ := resultMap["taskId"].(string)
					callback, _ := resultMap["callback"].(string)
					videoLevel, _ := resultMap["level"].(json.Number).Int64()
					if videoLevel == 0 {
						fmt.Printf("视频正常, taskId: %s, callback: %s", taskId, callback)
					} else if videoLevel == 1 || videoLevel == 2 {
						evidenceArray := resultMap["evidences"].([]interface{})
						for _, evidence := range evidenceArray {
							if evidenceMap, ok := evidence.(map[string]interface{}); ok {
								_, _ = evidenceMap["beginTime"].(json.Number).Int64()
								_, _ = evidenceMap["endTime"].(json.Number).Int64()
								_, _ = evidenceMap["type"].(json.Number).Int64()
								_, _ = evidenceMap["url"].(string)
								labelArray, _ := evidenceMap["labels"].([]interface{})
								for _, labelItem := range labelArray {
									if labelItemMap, ok := labelItem.(map[string]interface{}); ok {
										_, _ = labelItemMap["label"].(json.Number).Int64()
										_, _ = labelItemMap["level"].(json.Number).Int64()
										_, _ = labelItemMap["rate"].(json.Number).Float64()
									}
								}
								fmt.Printf("taskId: %s, %d, callback: %s, 证据信息: %s, 证据分类: %s", taskId, videoLevel, callback, evidence, labelArray)
							}
						}
					}
				}
			}
		}
	} else {
		fmt.Printf("ERROR: code=%d, msg=%s", code, message)
	}
}

响应示例

输出结果:

{
    "code": 200,
    "msg": "ok",
    "result": [
        {
            "status": "0",
            "taskId": "23d6e2abc1894512902e92928540a896",
            "level": 2,
            "evidences": [
                {
                    "beginTime": 1469774975520,
                    "endTime": 1469774975520,
                    "type": 1,
                    "url": "http://xxx.nos.netease.com/xxx1.jpeg",
                    "labels": [
                        {
                            "label": 100,
                            "level": 2,
                            "rate": 1
                        }
                    ]
                },
                {
                    "beginTime": 1469774975520,
                    "endTime": 1469774975520,
                    "type": 1,
                    "url": "http://xxx.nos.netease.com/xxx2.jpeg",
                    "labels": [
                        {
                            "label": 500,
                            "level": 1,
                             "rate": 0.96,
	                           "subLabels": [{
		               		                  "subLabel": 50003,
		               	         	          "rate": 1.0,
				                                "details": {
				                    	           "hitInfos": ["XXX"]
                                      }
                                     ]
                        }
                    ]
                }
            ]
        },
        {
            "status": "0",
            "taskId": "40d7e2fba1894512902e92928540a647",
            "level": 0,
            "evidences": [
                
            ]
        }
    ]
}
QQ咨询:反馈更及时 在线咨询 电话咨询:95163223