推送模式

2024.03.26 09:56:56

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

    接口说明

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

    鉴权说明

    易盾内容安全服务使用签名方法对接口进行鉴权,所有接口每一次请求都需要包含签名信息(signature 参数),以验证用户身份,防止信息被恶意篡改。目前支持 MD5,SHA1,SHA256,SM3 几种加密算法,详细信息,请参见接口鉴权

    接入说明

    • 协议说明:检测接口请求参数中指定了回调地址参数 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 字符串,主动推送数据格式和字段描述请参考轮询模式响应结果格式说明

    请求体示例

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

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

    机审结构

    
        "antispam": {
            "checkStatus": 2,
            "dataId": "123",
            "suggestion": 2,
            "callback": "i am callback",
            "evidences": {
                "images": [
                    {
                        "dataId": "525875",
                        "field": "content",
                        "suggestion": 2,
                        "censorType": 0,
                        "name": "mp84l9cwy8eqfxydqnx53vug05009pgw",
                        "resultType": 1,
                        "labels": [
                            {
                                "subLabels": [
                                    {
                                        "subLabel": "50003",
                                        "rate": 1.0,
                                        "details": {
                                            "hitInfos": [
                                                {
                                                    "y1": 0.1756,
                                                    "y2": 0.7165,
                                                    "x1": 0.1711,
                                                    "x2": 0.8457,
                                                    "value": "李四"
                                                }
                                            ]
                                        }
                                    }
                                ],
                                "level": 2,
                                "rate": 1.0,
                                "label": 500
                            },
                            {
                                "level": 0,
                                "rate": 1.0,
                                "label": 300
                            }
                        ],
                        "status": 2
                    }
                ],
                "texts": [
                    {
                        "dataId": "216292",
                        "field": "content",
                        "suggestion": 2,
                        "censorType": 0,
                        "isRelatedHit": false,
                        "resultType": 1,
                        "labels": [
                            {
                                "subLabels": [
                                    {
                                        "subLabel": "100080",
                                        "details": {
                                            "hitInfos": [
                                                {
                                                    "positions": [
                                                        {
                                                            "fieldName": "content",
                                                            "startPos": 0,
                                                            "endPos": 2
                                                        }
                                                    ],
                                                    "value": "测试"
                                                }
                                            ],
                                            "keywords": [
                                                {
                                                    "word": "测试"
                                                }
                                            ]
                                        }
                                    },
                                    {
                                        "subLabel": "100002"
                                    }
                                ],
                                "level": 2,
                                "label": 100
                            },
                            {
                                "subLabels": [
                                    {
                                        "subLabel": "500001",
                                        "details": {
                                            "hitInfos": [
                                                {
                                                    "positions": [
                                                        {
                                                            "fieldName": "content",
                                                            "startPos": 15,
                                                            "endPos": 18
                                                        }
                                                    ],
                                                    "value": "测试"
                                                }
                                            ]
                                        }
                                    },
                                    {
                                        "subLabel": "500015"
                                    }
                                ],
                                "level": 2,
                                "label": 500
                            },
                            {
                                "level": 0,
                                "label": 200
                            }
                        ]
                    }
                ],
                "audios": [
                    {
                        "duration": 25000,
                        "checkTime": 1630485845599,
                        "dataId": "330957",
                        "field": "content",
                        "suggestion": 2,
                        "resultType": 1,
                        "segments": [
                            {
                                "startTime": 0,
                                "endTime": 25,
                                "type": 0,
                                "content": "测试文本测试文本",
                                "labels": [
                                    {
                                        "subLabels": [
                                            {
                                                "subLabel": "500013",
                                                "details": {
                                                    "hitInfos": [
                                                        {
                                                            "value": "测试"
                                                        },
                                                        {
                                                            "value": "测,测试"
                                                        }
                                                    ]
                                                }
                                            }
                                        ],
                                        "level": 2,
                                        "label": 500
                                    }
                                ]
                            }
                        ],
                        "status": 2
                    }
                ],
                "audiovideos": [
                    {
                        "duration": 71339,
                        "checkTime": 1630485848287,
                        "dataId": "709664",
                        "field": "content",
                        "suggestion": 2,
                        "evidences": {
                            "audio": {
                                "duration": 71,
                                "suggestion": 2,
                                "resultType": 1,
                                "segments": [
                                    {
                                        "startTime": 12,
                                        "endTime": 17,
                                        "type": 1,
                                        "content": "命中声纹检测",
                                        "labels": [
                                            {
                                                "subLabels": [
                                                    {
                                                        "subLabel": "13000",
                                                        "details": {
                                                            "hitInfos": [
                                                                {
                                                                    "value": "1.00"
                                                                }
                                                            ]
                                                        }
                                                    }
                                                ],
                                                "level": 2,
                                                "label": 100
                                            }
                                        ]
                                    },
                                    {
                                        "startTime": 15,
                                        "endTime": 20,
                                        "type": 1,
                                        "content": "命中声纹检测",
                                        "labels": [
                                            {
                                                "subLabels": [
                                                    {
                                                        "subLabel": "13000",
                                                        "details": {
                                                            "hitInfos": [
                                                                {
                                                                    "value": "1.00"
                                                                }
                                                            ]
                                                        }
                                                    }
                                                ],
                                                "level": 2,
                                                "label": 100
                                            }
                                        ]
                                    }
                                ],
                                "status": 2
                            },
                            "video": {
                                "duration": 71,
                                "suggestion": 2,
                                "resultType": 1,
                                "pictures": [
                                    {
                                        "backPics": [
                                            {
                                                "url": "https://123.jpg"
                                            }
                                        ],
                                        "frontPics": [
                                            {
                                                "url": "https://456.jpg"
                                            }
                                        ],
                                        "startTime": 5000,
                                        "endTime": 5000,
                                        "type": 1,
                                        "url": "789.jpg",
                                        "labels": [
                                            {
                                                "subLabels": [
                                                    {
                                                        "subLabel": "10007",
                                                        "rate": 0.926,
                                                        "details": {
                                                            "hitInfos": [
                                                                {
                                                                    "value": "卡通色情",
                                                                    "group": "色情部位分组"
                                                                }
                                                            ]
                                                        }
                                                    }
                                                ],
                                                "level": 2,
                                                "rate": 0.95157,
                                                "label": 100
                                            }
                                        ]
                                    }
                                ],
                                "status": 2
                            }
                        },
                        "resultType": 1,
                        "status": 2
                    }
                ]
            },
            "resultType": 1,
            "taskId": "mp84l9cwy8eqfxydqnx53vug05009pgw"
        },
        "valueAddService": {
            "emotionAnalysis": {
                "texts": [
                    {
                        "dataId": "192470",
                        "field": "image1",
                        "details": [
                            {
                                "sentiment": "positive",
                                "positiveProb": 0.7576994299888611,
                                "negativeProb": 0.24208970367908478
                            }
                        ],
                        "taskId": "81uoe1igu601b2v2wfoik3fg05009pgr"
                    }
                ]
            },
            "face": {
                "images": [
                    {
                        "dataId": "792707",
                        "field": "image1",
                        "details": [
                            {
                                "faceContents": [
                                    {
                                        "maskType": "normal",
                                        "expression": "happy",
                                        "gender": "male",
                                        "y1": 0.1756,
                                        "name": "张三",
                                        "y2": 0.7165,
                                        "x1": 0.1711,
                                        "x2": 0.8457,
                                        "type": "normal",
                                        "category": "normal",
                                        "beautyScore": 0.49,
                                        "age": 50
                                    }
                                ],
                                "faceNumber": 1
                            }
                        ],
                        "taskId": "81uoe1igu601b2v2wfoik3fg05009pgr"
                    }
                ]
            },
            "imageDiscern": {
                "images": [
                    {
                        "dataId": "792707",
                        "field": "image1",
                        "details": [
                            {
                                "rate": 0.9593,
                                "type": 3,
                                "discernName": "张三"
                            },
                            {
                                "rate": 0.755,
                                "type": 3,
                                "discernName": "人物特写"
                            },
                            {
                                "rate": 0.4752,
                                "type": 3,
                                "discernName": "人脸"
                            }
                        ],
                        "taskId": "81uoe1igu601b2v2wfoik3fg05009pgr"
                    }
                ]
            },
            "logo": {
                "images": [
                    {
                        "dataId": "792707",
                        "field": "image1",
                        "details": [
                            
                        ],
                        "taskId": "81uoe1igu601b2v2wfoik3fg05009pgr"
                    }
                ]
            },
            "language": {
                "texts": [
                    {
                        "dataId": "192470",
                        "field": "image1",
                        "details": [
                            {
                                "type": "zh"
                            }
                        ],
                        "taskId": "81uoe1igu601b2v2wfoik3fg05009pgr"
                    }
                ]
            },
            "imageQuality": {
                "images": [
                    {
                        "dataId": "792707",
                        "field": "image1",
                        "details": [
                            {
                                "metaInfo": {
                                    "byteSize": 124343,
                                    "format": "png",
                                    "width": 267,
                                    "height": 333
                                },
                                "sharpnessRate": 0.7394,
                                "aestheticsRate": 0.6262,
                                "boarderInfo": {
                                    "hit": false,
                                    "top": false,
                                    "left": false,
                                    "bottom": false,
                                    "right": false
                                },
                                "backgroundInfo": {
                                    "pureBackground": false
                                }
                            }
                        ],
                        "taskId": "81uoe1igu601b2v2wfoik3fg05009pgr"
                    }
                ]
            },
            "ocr": {
                "images": [
                    {
                        "dataId": "792707",
                        "field": "image1",
                        "width": 267,
                        "details": [
                            
                        ],
                        "taskId": "81uoe1igu601b2v2wfoik3fg05009pgr",
                        "height": 333
                    }
                ]
            }
        },
        "anticheat": {
            "suggestion": 2,
            "taskId": "81uoe1igu601b2v2wfoik3fg05009pgr",
            "hitInfo": {
                "hitType": 3
            }
        }
    
        "censor": {
            "censorLabels": [
                {
                    "code": "1600759147543",
                    "name": "变形金刚",
                    "desc": "变形金刚/地球"
                },
                {
                    "code": "1600762076926",
                    "name": "地球",
                    "desc": ""
                }
            ],
            "suggestion": 2,
            "censorRound": 0,
            "censorTime": 1630549946549,
            "reviewEvidences": {
                "reason": "其他",
                "remark": "",
                "detail": {
                    "images": [
                        {
                            "censorResult": 0,
                            "reasons": [
                                {
                                    "censorLabels": [
                                        
                                    ],
                                    "reason": "违规图片",
                                    "url": "https://image.jpg"
                                }
                            ],
                            "dataId": "809577",
                            "field": "content"
                        }
                    ],
                    "texts": [
                        {
                            "censorResult": 2,
                            "reasons": [
                                {
                                    "censorLabels": [
                                        
                                    ],
                                    "reason": "违规文本",
                                    "text": "异常的异常"
                                }
                            ],
                            "dataId": "427331",
                            "field": "content"
                        },
                        {
                            "censorResult": 1,
                            "dataId": "8114",
                            "field": "content"
                        }
                    ],
                    "audios": [
                        {
                            "censorResult": 2,
                            "dataId": "855180",
                            "field": "content",
                            "reasons": [
                                {
                                    "censorLabels": [
                                        
                                    ],
                                    "reason": "音频违规",
                                    "startTime": 0,
                                    "endTime": 0,
                                    "url": "https://audio.mp3"
                                }
                            ]
                        }
                    ],
                    "files": [
                        {
                            "censorResult": 2,
                            "dataId": "855180",
                            "field": "content",
                            "texts": [
                                {
                                    "censorLabels": [
                                        
                                    ],
                                    "reason": "违规文本",
                                    "text": "异常的异常"
                                }
                            ],
                            "images": [
                                {
                                    "censorLabels": [
                                        
                                    ],
                                    "reason": "违规图片",
                                    "url": "https://image.jpg"
                                }
                            ]
                        }
                    ],
                    "videos": [
                        {
                            "censorResult": 2,
                            "dataId": "855180",
                            "field": "content",
                            "reasons": [
                                {
                                    "censorLabels": [
                                        
                                    ],
                                    "reason": "视频中图片违规",
                                    "startTime": 0,
                                    "endTime": 0,
                                    "url": "https://video.mp4"
                                }
                            ]
                        }
                    ],
                    "audiovideos": [
                        {
                            "censorResult": 2,
                            "dataId": "855180",
                            "field": "content",
                            "audios": [
                                {
                                    "censorLabels": [
                                        
                                    ],
                                    "reason": "音频违规",
                                    "startTime": 0,
                                    "endTime": 0,
                                    "url": "https://video.mp4"
                                }
                            ],
                            "videos": [
                                {
                                    "censorLabels": [
                                        
                                    ],
                                    "reason": "视频中图片违规",
                                    "startTime": 0,
                                    "endTime": 0,
                                    "url": "https://video.mp4"
                                }
                            ]
                        }
                    ]
                }
            },
            "skipCensor": 0,
            "censorSource": 0,
            "resultType": 2,
            "taskId": "x4vo2xy2whrd3ovnsb7dplhg05009phe"
        }
    
    

    响应

    响应结果

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

    响应体示例

    { 
        "code": 200, 
        "msg": "接收成功"
    }
    
    在线咨询 电话咨询:95163223 免费试用