推送模式

2022.09.22 16:33:43

    内容安全点播音视频结果获取推送模式用于将点播音视频异步检测或人工审核结果主动推送给客户,保证客户最快的获取结果。客户需要按照以下规范实现接收结果的接口。推送模式与轮询模式互斥,只能选取一种模式进行结果获取。

    接口说明

    结果主动推送模式以数据为维度,将异步机器检测结果或者人工审核结果推送给客户,需客户在调用检测接口时设置回调地址callbackUrl参数,客户方需保证回调接收接口的可用性和稳定性,确保能正常接收推送过来的结果数据。

    鉴权说明

    客户接口可以通过业务开通时易盾分配的密钥信息字段进行接口鉴权,鉴权粒度是否要精确到业务级别,用户可以根据需要自行决定,请参见接口鉴权

    接入说明

    • 协议说明:检测接口请求参数中指定了回调地址参数callbackUrl(即一个http(s)协议接口的URL)。主动推送接口需要支持http协议,支持POST方法,传输数据编码采用utf-8
    • 接口性能:推送结果接口默认超时时间为2s,为了保证顺利接收数据,客户需保证接收接口可用性和性能稳定
    • 失败重试:客户接口处理结果数据,并返回应答。如果客户接口请求异常,超时或收到的应答不符合规范,易盾会认为推送失败;我们将每隔10分钟推送一次,如果一直失败,持续一天后不再推送
    • 幂等性:结果推送时同样的结果可能会多次请求客户接口。客户接口需要保证幂等性,能够正确处理重复结果数据

    接口耗时

    客户接收接口需保证接收接口可用性和性能稳定,易盾请求超时时间为2s,客户接口尽量保证在1s内返回应答,如有特殊要求,可联系易盾运营适当调整超时时间

    请求

    请求地址

    名称
    HTTP URL 回调地址callbackUrl
    HTTP Method POST

    请求头

    名称 类型 必填 描述
    Content-Type String 固定值:"application/x-www-form-urlencoded"

    请求参数

    名称 类型 必填 最大长度 描述
    secretId String 32 产品秘钥 id ,由易盾内容安全云服务分配,产品标识
    signature String 32 请求签名,用来验证此次请求的合法性,具体算法见接口鉴权
    callbackData String - 主动推送结果数据,格式为json字符串,主动推送数据格式和字段描述请参考轮询模式响应结果格式说明,请查看返回antispam机审结构

    请求体示例

    callbackData=***&signature=xxx&secretId=xxx
    

    请求体callbackData格式如下,callbackData为json字符串格式,请自行解析或者反转成json对象使用

    {
        "antispam":{
            "taskId":"18xrunm6fr35t49nnv506ukg02009q66",
            "suggestion":2,
            "status":2,
            "resultType":1,
            "censorSource":2,
            "checkTime":1633759861164,
            "censorTime":1633759853762,
            "duration":71339,
            "censorLabels":[
                {
                    "code":101,
                    "desc":"自定义标签",
                    "customCode":"68684"
                }
            ],
            "evidences":{
                "images":[
                    {
                        "censorType":0,
                        "labels":[
                            {
                                "label":100,
                                "level":2,
                                "rate":0.9999,
                                "subLabels":[
                                    {
                                        "details":{
                                            "hitInfos":[
                                                {
                                                    "group":"色情部位分组",
                                                    "value":"女胸"
                                                }
                                            ]
                                        },
                                        "rate":1,
                                        "subLabel":10002
                                    }
                                ]
                            },
                            {
                                "label":500,
                                "level":0,
                                "rate":0.9999
                            },
                            {
                                "label":300,
                                "level":0,
                                "rate":1
                            },
                            {
                                "label":400,
                                "level":0,
                                "rate":1
                            },
                            {
                                "label":200,
                                "level":0,
                                "rate":0.9975
                            }
                        ],
                        "name":"gpqis0e92czvfliemjpa3neg02009q6a",
                        "resultType":1,
                        "status":2,
                        "suggestion":2,
                        "taskId":"0b2dd0e561a8457fbfcf7d79378eec37"
                    }
                ],
                "text":{
                    "taskId":"44i3effo1j5w5for9l8xtdjg02009q6a",
                    "suggestion":2,
                    "resultType":1,
                    "censorType":0,
                    "isRelatedHit":false,
                    "labels":[
                        {
                            "label":200,
                            "level":2,
                            "subLabels":[
                                {
                                    "subLabel":"200009",
                                    "details":{
                                        "hitInfos":[
                                            {
                                                "value":"加我",
                                                "positions":[
                                                    {
                                                        "fieldName":"content",
                                                        "startPos":5,
                                                        "endPos":8
                                                    },
                                                    {
                                                        "fieldName":"title",
                                                        "startPos":5,
                                                        "endPos":8
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                "audio":{
                    "taskId":"18xrunm6fr35t49nnv506ukg02009q66",
                    "dataId":"",
                    "status":2,
                    "suggestion":2,
                    "resultType":1,
                    "callback":"",
                    "censorSource":2,
                    "censorTime":1633759861065,
                    "segments":[
                        {
                            "startTime":0,
                            "endTime":6,
                            "content":"第一次用这个软件上了半天,全是长得漂亮呢?",
                            "type":0,
                            "labels":[
                                {
                                    "label":500521,
                                    "level":2,
                                    "subLabels":[
                                        {
                                            "subLabel":"100001",
                                            "details":{
                                                "hitInfos":[
                                                    {
                                                        "value":"120",
                                                        "startTime":1684201,
                                                        "endTime":1684201,
                                                        
                                                    }
                                                ],
                                                "keywords":[
                                                    {
                                                        "word":"自定义敏感词"
                                                    }
                                                ],
                                                "libInfos":[
                                                    {
                                                        "listType":1,
                                                        "entity":"127.0.0.1"
                                                    }
                                                ]
                                            }
                                        }
                                    ]
                                }
                            ]
                        },
                        {
                            "startTime":52,
                            "endTime":53,
                            "content":"哦。",
                            "type":0,
                            "labels":[
    
                            ]
                        }
                    ],
                    "duration":71
                },
                "video":{
                    "taskId":"18xrunm6fr35t49nnv506ukg02009q66",
                    "dataId":"",
                    "status":2,
                    "suggestion":2,
                    "resultType":1,
                    "censorSource":2,
                    "censorTime":1633759858920,
                    "pictures":[
                        {
                            "type":1,
                            "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_1_5000.jpg?Signature=zAyZL%2B8cuIZlQyAguVxzeXtoSB20NYykv32i9IQpdQI%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8",
                            "startTime":5000,
                            "endTime":5000,
                            "labels":[
                                {
                                    "label":100,
                                    "level":2,
                                    "rate":0.95157,
                                    "subLabels":[
                                        {
                                            "subLabel":10007,
                                            "rate":0.926,
                                            "details":{
                                                "hitInfos":[
                                                    {
                                                        "value":"卡通色情",
                                                        "group":"色情部位分组"
                                                    }
                                                ]
                                            }
                                        }
                                    ]
                                }
                            ],
                            "censorSource":2,
                            "frontPics":[
                                {
                                    "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_0_0.jpg?Signature=OLZBW0E1tD21RTp7JD58hB1xuwwhd%2FDbeMXFSxOTL%2FU%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8"
                                }
                            ],
                            "backPics":[
                                {
                                    "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_2_10000.jpg?Signature=6mtVdESs0R%2BwzRVE%2BmVYT8RVVh1nllu%2FO1dkaQJwMAc%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8"
                                },
                                {
                                    "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_3_15000.jpg?Signature=qekds78dhYRIrhXw6NK7Xh88nW18FObulqA6aPU7Mcg%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8"
                                },
                                {
                                    "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_4_20000.jpg?Signature=ZyrIX4TJP5MpOYoPRhVTf6L%2BelcNJFlnt7t8J7ucwKk%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8"
                                }
                            ]
                        },
                        {
                            "type":1,
                            "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_2_10000.jpg?Signature=6mtVdESs0R%2BwzRVE%2BmVYT8RVVh1nllu%2FO1dkaQJwMAc%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8",
                            "startTime":10000,
                            "endTime":10000,
                            "labels":[
                                {
                                    "label":100,
                                    "level":2,
                                    "rate":0.95157,
                                    "subLabels":[
                                        {
                                            "subLabel":10007,
                                            "rate":0.926,
                                            "details":{
                                                "hitInfos":[
                                                    {
                                                        "value":"卡通色情",
                                                        "group":"色情部位分组"
                                                    }
                                                ]
                                            }
                                        }
                                    ]
                                }
                            ],
                            "censorSource":2,
                            "frontPics":[
                                {
                                    "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_0_0.jpg?Signature=OLZBW0E1tD21RTp7JD58hB1xuwwhd%2FDbeMXFSxOTL%2FU%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8"
                                },
                                {
                                    "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_1_5000.jpg?Signature=zAyZL%2B8cuIZlQyAguVxzeXtoSB20NYykv32i9IQpdQI%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8"
                                }
                            ],
                            "backPics":[
                                {
                                    "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_3_15000.jpg?Signature=qekds78dhYRIrhXw6NK7Xh88nW18FObulqA6aPU7Mcg%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8"
                                },
                                {
                                    "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_4_20000.jpg?Signature=ZyrIX4TJP5MpOYoPRhVTf6L%2BelcNJFlnt7t8J7ucwKk%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8"
                                },
                                {
                                    "url":"https://illegal-video.nosdn.127.net/18xrunm6fr35t49nnv506ukg02009q66_5_25000.jpg?Signature=exB1s%2BEQoMq%2FL4BZqyMofQB8H%2FwkiinkpFjG39mDpl0%3D&Expires=1636351861&NOSAccessKeyId=7ec43af9b5bf4ca5975204de64396ee8"
                                }
                            ]
                        }
                    ],
                    "duration":71
                }
            }
        },
        "language":{
            "taskId":"38e08da8d2574df4bd2eca9b5153df72",
            "dataId":"",
            "callback":"",
            "details":[
                {
                    "type":"en-GB",
                    "segments":[
                        {
                            "startTime":35,
                            "endTime":40
                        },
                        {
                            "startTime":160,
                            "endTime":165
                        }
                    ]
                }
            ]
        },
        "asr":{
            "taskId":"38e08da8d2574df4bd2eca9b5153df72",
            "dataId":"",
            "callback":"",
            "details":[
                {
                    "startTime":0,
                    "endTime":15,
                    "content":"5月15日,我国首次火星探测任务着陆火星取得成功。"
                }
            ]
        },
        "voice":{
            "taskId":"7f03cdeaf4cf4c748a4edbe97833a9ee",
            "dataId":"",
            "callback":"",
            "details":{
                "mainGender":"male"
             }
            
        }
    }
    

    响应

    响应结果

    • 客户接口接收到我们回调的结果后,需要返回应答信息,接口响应HTTP状态码为200,当回调处理异常时,应答的HTTP状态码应为500,或者4xx;
    • 目前推送方式默认连接超时(connect timeout)150ms,回调超时(socket timeout)为2s,建议收到推送检测结果后,优先返回reponse应答信息,异步处理检测结果,避免因为回调超时,易盾侧未收到响应重复推送结果。如业务侧对于超时配置有特殊要求,可联系易盾策略经理调整配置。
    • 应答信息为json格式,字段定义如下:
    名称 类型 必须返回 描述
    code Number 应答code,易盾方解析code为200表示推送成功
    msg String 具体描述信息

    响应体示例

    { 
        "code": 200, 
        "msg": "接收成功"
    }
    
    Online Chat Tel:95163223