图片防刷版开发文档

防刷版说明

防刷版将融合反作弊能力综合判定内容安全检测结果,目前易盾支持如下两种防刷版接入方式,对比如下:

API防刷版SDK防刷版
接入方式服务器api接口前端接入SDK+服务器API接口
获取信息防刷字段(手机号、邮箱号、用户名、IP)+自定义扩展字设备基本信息+设备指纹+防刷业务数据防刷字段(手机号、邮箱号、用户名、IP)+自定义扩展字
优势说明接入简单获取信息更多
效果说明对比非防刷版,效果有较高提升对比非防刷版,效果显著提升

请根据自身产品情况选择接入不同模式的防刷版检测;

SDK防刷版开发文档

开发流程图

SDK防刷版调用示意图

步骤1:接入反作弊SDK

接入请参考:http://support.dun.163.com/documents/15588071870066688?docId=70966851765719040&locale=zh-cn

步骤2:接入图片检测api,传入反作弊token字段

接口地址

http://as.dun.163.com/v4/image/check

接口描述

该接口同步返回内容安全服务实时反垃圾引擎检测结果,产品根据图片分类结果,做图片初步过滤。由于网络环境及图片本身大小的影响(建议产品对图片进行压缩后,再过反垃圾检测),部分图片可能出现下载超时情况,该部分数据会返回检测失败,请重新检测。机器离线检测后,可能会有部分不确定的数据需要人工进一步确认。离线检测结果及人工确认结果需产品自行定期调用图片离线检测结果获取

V3在线检测接口文档请点此下载查看

图片限制

◆ 目前支持的图片文件格式有:jpg, png, bmp, gif, webp, tiff;

◆ 支持图片大小:单张<10M;

◆ 图片尺寸大小:不小于 50px*50px;

◆ gif图长图说明:易盾自动将gif图长图截帧过检,最多5张,gif图长图均按照实际截图张数进行计费;

◆ 长图定义:长宽比大于5的图片

请求参数

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

基本参数
参数名称类型是否必选最大长度描述
imagesString(json数组)Y32张或10MBimages为json数组,支持批量检测
versionStringY4接口版本v4

images参数结构说明

字段名称类型是否必选最大长度描述
nameStringY1024图片名称(或图片标识), 该字段为回调信号字段,产品可以根据业务情况自行设计,如json结构、或者为图片url均可
typeNumberY4类型,分别为1:图片URL,2:图片BASE64值
dataStringY32张或者10MB图片内容,如type=1,则该值为图片URL,如type=2,则该值为图片BASE64值。图片URL检测单次请求最多支持32张,图片BASE64值检测单次请求大小限制为最多10MB
callbackUrlStringN256离线结果回调通知到客户的URL。主动回调数据接口超时时间设置为2s,为了保证顺利接收数据,需保证接收接口性能稳定并且保证幂等性。
业务参数

业务扩展参数,有助于通过业务维度辅助反垃圾结果判定,建议传入。

参数名称类型是否必选最大长度描述
ipStringN32用户IP地址
accountStringN128用户唯一标识,如果无需登录则为空
deviceTypeNumberN4用户设备类型,1:web, 2:wap, 3:android, 4:iphone, 5:ipad, 6:pc, 7:wp
deviceIdStringN128用户设备 id
反垃圾防刷版专属字段

如在您的内容检测场景中,存在一定作弊行为,建议开启反垃圾防刷版,如下参数,需开启反垃圾防刷功能后,传入方可生效,如需开启,请联系您的专属商务

参数名称类型是否必选最大长度描述
emailStringN64用户邮箱
phoneStringN11用户手机号
tokenStringN256来自易盾反作弊SDK返回的token
extensionjsonN512扩展字段
扩展参数
参数名称类型是否必选最大长度描述
checkLabelsString数组N64接口指定过检分类,可多选,指定后业务配置过检分类即失效,过检分类列表:100:色情,110:性感低俗,200:广告,210:二维码,260:广告法,300:暴恐,400:违禁,500:涉政

响应结果

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

反垃圾结果

antispam 数组数据结构

参数名称类型描述
nameString图片名称(或图片标识)
taskIdString本次请求数据标识,可以根据该标识查询数据最新结果
statusNumber图片检测状态码,定义为:0:检测成功,610:图片下载失败,620:图片格式错误,630:其它
actionjson对象建议动作,2:建议删除,1:建议审核,0:建议通过
labelsjson数组分类信息

labels 数据结构

参数名称类型描述
labelNumber分类信息,100:色情,110:性感低俗,200:广告,210:二维码,260:广告法,300:暴恐,400:违禁,500:涉政,900:其他
subLabelsjson数组细分类信息,可能包含多个,可能为空
leveljson对象分类级别,0:正常,1:不确定,2:确定
rateNumber置信度分数,0-1之间取值,1为置信度最高,0为置信度最低。若level为正常,置信度越大,说明正常的可能性越高。若level为不确定或确定,置信度越大,说明垃圾的可能性越高

subLabels 数据结构

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

subLabel细分类编码对应表

返回编码描述hitInfos
10000色情若命中图片中文字检测策略,可返回文字线索信息
10001女下体-
10002女胸-
10003男下体-
10004性行为-
10005臀部-
10006口交-
10007卡通色情-
10008色情人物人物名
10009儿童色情-
11000性感低俗-
11001亲吻-
20000广告若命中图片中文字检测策略,可返回文字线索信息
21000二维码若命中图片中文字检测策略,可返回文字线索信息
30000暴恐若命中图片中文字检测策略,可返回文字线索信息
30001暴恐图集-
30002暴恐旗帜旗帜名
30003暴恐人物人物名
30004暴恐标识标识名
30005暴恐场景场景名
40000违禁若命中图片中文字检测策略,可返回文字线索信息
40001违禁图集-
40002违禁品违禁品名
40003特殊标识标识名
40004血腥模型-
40005公职服饰服饰名
40006不文明不文明行为
40007违禁人物人物名
40008违禁场景场景名
40009火焰-
40010骷髅-
40011货币-
50000涉政若命中图片中文字检测策略,可返回文字线索信息
50001涉政图集-
50002中国地图-
50003涉政人物人物名
50004涉政旗帜旗帜名
50005涉政标识标识名
50006涉政场景场景名
90000其他-
90002自定义用户名单名单列表
90003自定义IP名单名单列表

自定义细分类

易盾支持sublabel自定义细分类过检并返回,如有需求,可联系您的专属运营经理添加。

API防刷版开发文档

接口地址

http://as.dun.163.com/v4/image/check

接口描述

该接口同步返回内容安全服务实时反垃圾引擎检测结果,产品根据图片分类结果,做图片初步过滤。由于网络环境及图片本身大小的影响(建议产品对图片进行压缩后,再过反垃圾检测),部分图片可能出现下载超时情况,该部分数据会返回检测失败,请重新检测。机器离线检测后,可能会有部分不确定的数据需要人工进一步确认。离线检测结果及人工确认结果需产品自行定期调用图片离线检测结果获取

V3在线检测接口文档请点此下载查看

图片限制

◆ 目前支持的图片文件格式有:jpg, png, bmp, gif, webp, tiff;

◆ 支持图片大小:单张<10M;

◆ 图片尺寸大小:不小于 50px*50px;

◆ gif图长图说明:易盾自动将gif图长图截帧过检,最多5张,gif图长图均按照实际截图张数进行计费;

◆ 长图定义:长宽比大于5的图片

请求参数

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

基本参数

参数名称类型是否必选最大长度描述
imagesString(json数组)Y32张或10MBimages为json数组,支持批量检测
versionStringY4接口版本v4

images参数结构说明

字段名称类型是否必选最大长度描述
nameStringY1024图片名称(或图片标识), 该字段为回调信号字段,产品可以根据业务情况自行设计,如json结构、或者为图片url均可
typeNumberY4类型,分别为1:图片URL,2:图片BASE64值
dataStringY32张或者10MB图片内容,如type=1,则该值为图片URL,如type=2,则该值为图片BASE64值。图片URL检测单次请求最多支持32张,图片BASE64值检测单次请求大小限制为最多10MB
callbackUrlStringN256离线结果回调通知到客户的URL。主动回调数据接口超时时间设置为2s,为了保证顺利接收数据,需保证接收接口性能稳定并且保证幂等性。

业务参数

业务扩展参数,有助于通过业务维度辅助反垃圾结果判定,建议传入。

参数名称类型是否必选最大长度描述
ipStringN32用户IP地址
accountStringN128用户唯一标识,如果无需登录则为空
deviceTypeNumberN4用户设备类型,1:web, 2:wap, 3:android, 4:iphone, 5:ipad, 6:pc, 7:wp
deviceIdStringN128用户设备 id

反垃圾防刷版专属字段

如在您的内容检测场景中,存在一定作弊行为,建议开启反垃圾防刷版,如下参数,需开启反垃圾防刷功能后,传入方可生效,如需开启,请联系您的专属商务

参数名称类型是否必选最大长度描述
emailStringN64用户邮箱
phoneStringN11用户手机号
extensionjsonN512扩展字段

扩展参数

参数名称类型是否必选最大长度描述
checkLabelsString数组N64接口指定过检分类,可多选,指定后业务配置过检分类即失效,过检分类列表:100:色情,110:性感低俗,200:广告,210:二维码,300:暴恐,400:违禁,500:涉政

响应结果

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

反垃圾结果

antispam 数组数据结构

参数名称类型描述
nameString图片名称(或图片标识)
taskIdString本次请求数据标识,可以根据该标识查询数据最新结果
statusNumber图片检测状态码,定义为:0:检测成功,610:图片下载失败,620:图片格式错误,630:其它
actionjson对象建议动作,2:建议删除,1:建议审核,0:建议通过
labelsjson数组分类信息

labels 数据结构

参数名称类型描述
labelNumber分类信息,100:色情,110:性感低俗,200:广告,210:二维码,300:暴恐,400:违禁,500:涉政,900:其他
subLabelsjson数组细分类信息,可能包含多个,可能为空
leveljson对象分类级别,0:正常,1:不确定,2:确定
rateNumber置信度分数,0-1之间取值,1为置信度最高,0为置信度最低。若level为正常,置信度越大,说明正常的可能性越高。若level为不确定或确定,置信度越大,说明垃圾的可能性越高

subLabels 数据结构

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

subLabel细分类编码对应表

返回编码描述hitInfos
10000色情若命中图片中文字检测策略,可返回文字线索信息
10001女下体-
10002女胸-
10003男下体-
10004性行为-
10005臀部-
10006口交-
10007卡通色情-
10008色情人物人物名
10009儿童色情-
11000性感低俗-
11001亲吻-
20000广告若命中图片中文字检测策略,可返回文字线索信息
21000二维码若命中图片中文字检测策略,可返回文字线索信息
30000暴恐若命中图片中文字检测策略,可返回文字线索信息
30001暴恐图集-
30002暴恐旗帜旗帜名
30003暴恐人物人物名
30004暴恐标识标识名
30005暴恐场景场景名
40000违禁若命中图片中文字检测策略,可返回文字线索信息
40001违禁图集-
40002违禁品违禁品名
40003特殊标识标识名
40004血腥模型-
40005公职服饰服饰名
40006不文明不文明行为
40007违禁人物人物名
40008违禁场景场景名
40009火焰-
40010骷髅-
40011货币-
50000涉政若命中图片中文字检测策略,可返回文字线索信息
50001涉政图集-
50002中国地图-
50003涉政人物人物名
50004涉政旗帜旗帜名
50005涉政标识标识名
50006涉政场景场景名
90000其他-
90002自定义用户名单名单列表
90003自定义IP名单名单列表

自定义细分类

易盾支持sublabel自定义细分类过检并返回,如有需求,可联系您的专属运营经理添加。

请求示例

    /** 产品密钥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 = "http://as.dun.163.com/v4/image/check";
    /** 实例化HttpClient,发送http请求使用,可根据需要自行调参 */
    private static HttpClient httpClient = HttpClient4Utils.createHttpClient(100, 20, 10000, 2000, 2000);

    /**
     *
     * @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", "v4");
        params.put("timestamp", String.valueOf(System.currentTimeMillis()));
        params.put("nonce", String.valueOf(new Random().nextInt()));

        // 2.设置私有参数
        JsonArray jsonArray = new JsonArray();
        // 传图片url进行检测,name结构产品自行设计,用于唯一定位该图片数据
        JsonObject image1 = new JsonObject();
        image1.addProperty("name", "http://p1.music.126.net/lEQvXzoC17AFKa6yrf-ldA==/1412872446212751.jpg");
        image1.addProperty("type", 1);
        image1.addProperty("data", "http://p1.music.126.net/lEQvXzoC17AFKa6yrf-ldA==/1412872446212751.jpg");
        jsonArray.add(image1);

        // 传图片base64编码进行检测,name结构产品自行设计,用于唯一定位该图片数据
        JsonObject image2 = new JsonObject();
        image2.addProperty("name", "{\"imageId\": 33451123, \"contentId\": 78978}");
        image2.addProperty("type", 2);
        image2.addProperty("data","iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAYNElEQVR4nO2dP3vivNKHnfc6FWmhZVvTAk9JvkPSLikfsvUpSZ18hpAtl7TJdyBlYFvThpa0UK7fwtf6OP4zM/ZIlk1+d5HLOytpRsbjGVmyfBaGoQcAcMf/uTYAgK8OnBAAx8AJAXAMnBAAx8AJAXAMnBAAx8AJAXAMnBAAx8AJAXBNSOLauvpYLBb0qWBZr9c12Pnw8FCDnUoVEhaLRQ2nqyHQpwKREADH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Y5KgGsoJElNTKQRIRwFwDJwQAMdgTGiyurB9jAk9o0m+0BKMCT0PY0KMCTEmzAPpKACOQTpqsrqwfaSjntH8QmhJY9NR7bK17XZbW16h4XA4SIqF3Ho6JZvNRtnCfr83YkmYeCHj7O8bUnIh274+eet0Or7vl+pUFnYtYb/fjz+lWC1IKC309E54fX2tN+LroPzI7inBXr6+7+vvWaPRiP6m6mKxoFcC1hBjMCYEwDFwwk/YHhM2hxaNCa0O1ZowJoQTfsL2FEVzaNEUhdWZA0xRAADghJ9BOioUsiAdlQMn/ATSUaGQBemoHDghAI6BEwLgGDjhJzAmFApZMCaUAyf8BMaEQiELxoRyzk7yCgOgRSASAuAYOCEAjoETAuAYOCEAjoETAuAYOCEAjoETAuAYOCEAjoETAuCY/wc8SC3r28PmnQAAAABJRU5ErkJggg==");

        jsonArray.add(image2);

        params.put("images", jsonArray.toString());
       // params.put("account", "java@163.com");
       // params.put("ip", "123.115.77.137");

        // 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 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("antispam");
            for (JsonElement jsonElement : resultArray) {
                JsonObject jObject = jsonElement.getAsJsonObject();
                String name = jObject.get("name").getAsString();
                String taskId = jObject.get("taskId").getAsString();
                JsonArray labelArray = jObject.get("labels").getAsJsonArray();
                System.out.println(String.format("taskId=%s,name=%s,labels:", taskId, name));
                int maxLevel = -1;
                // 产品需根据自身需求,自行解析处理,本示例只是简单判断分类级别
                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("label:%s, level=%s, rate=%s", label, level, rate));
                    maxLevel = level > maxLevel ? level : maxLevel;
                }
                switch (maxLevel) {
                    case 0:
                        System.out.println("#图片检测机器检测结果:最高等级为\"正常\"\n");
                        break;
                    case 1:
                        System.out.println("#图片检测机器检测结果:最高等级为\"嫌疑\"\n");
                        break;
                    case 2:
                        System.out.println("#图片检测机器检测结果:最高等级为\"确定\"\n");
                        break;
                    default:
                        break;
                }
            }
        } 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 image_check.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 ImageCheckAPIDemo(object):
    """图片在线检测接口示例代码"""

    API_URL = "http://as.dun.163.com/v4/image/check"
    VERSION = "v4"

    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=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 = ImageCheckAPIDemo(SECRET_ID, SECRET_KEY, BUSINESS_ID)

    # 私有请求参数
    images: list = []
    imageUrl = {
        "name": "https://nos.netease.com/yidun/2-0-0-a6133509763d4d6eac881a58f1791976.jpg",
        "type": 1,
        "data": "https://nos.netease.com/yidun/2-0-0-a6133509763d4d6eac881a58f1791976.jpg"
        # "callbackUrl"  # 主动回调地址url,如果设置了则走主动回调逻辑
    }
    imageBase64 = {
        "name": "{\"imageId\": 33451123, \"contentId\": 78978}",
        "type": 2,
        "data": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAYNElEQVR4nO2dP3vivNKHnfc6FWmhZVvTAk9JvkPSLikfsvUpSZ18hpAtl7TJdyBlYFvThpa0UK7fwtf6OP4zM/ZIlk1+d5HLOytpRsbjGVmyfBaGoQcAcMf/uTYAgK8OnBAAx8AJAXAMnBAAx8AJAXAMnBAAx8AJAXAMnBAAx8AJAXBNSOLauvpYLBb0qWBZr9c12Pnw8FCDnUoVEhaLRQ2nqyHQpwKREADHwAkBcAycUErYkuS8LXaCGDghAI6BE0o5OztzbYKIttgJYuCEUtqS5rXFThADJwTAMXBCABwDJwTAMXBCKW154NEWO0HMf5T1f/365fu+EVOscn19vd1urarwff/t7U3ZCGvn/f39z58/NSoOh4OmesR0OqXtnM/nV1dXGhW+7//69UvTQj1st9vr62tNC1on9H1/NBp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tN+LroPzI7inBXr6+7+vvWaPRiP6m6mKxoFcC1hBjMCYEwDFwwk/YHhM2hxaNCa0O1ZowJoQTfsL2FEVzaNEUhdWZA0xRAADghJ9BOioUsiAdlQMn/ATSUaGQBemoHDghAI6BEwLgGDjhJzAmFApZMCaUAyf8BMaEQiELxoRyzk7yCgOgRSASAuAYOCEAjoETAuAYOCEAjoETAuAYOCEAjoETAuAYOCEAjoETAuCY/wc8SC3r28PmnQAAAABJRU5ErkJggg=="
        # "callbackUrl": "http://***"  # 主动回调地址url,如果设置了则走主动回调逻辑
    }
    images.append(imageUrl)
    images.append(imageBase64)

    params = {
        "images": json.dumps(images)
        # "account": "python@163.com"
        # "ip": "123.115.77.137"
    }

    ret = api.check(params)

    code: int = ret["code"]
    msg: str = ret["msg"]
    if code == 200:
        # 图片反垃圾结果
        antispamArray: list = ret["antispam"]
        for antispamResult in antispamArray:
            name: str = antispamResult["name"]
            taskId: str = antispamResult["taskId"]
            status: int = antispamResult["status"]
            # 图片检测状态码,定义为:0:检测成功,610:图片下载失败,620:图片格式错误,630:其它
            if status == 0:
                # 图片维度结果
                action: int = antispamResult["action"]
                labelArray: list = antispamResult["labels"]
                print("taskId: %s, status: %s, name: %s, action: %s" % (taskId, status, name, action))
                # 产品需根据自身需求,自行解析处理,本示例只是简单判断分类级别
                for labelItem in labelArray:
                    label: int = labelItem["label"]
                    level: int = labelItem["level"]
                    rate: float = labelItem["rate"]
                    subLabels: list = labelItem["subLabels"]
                    print("label: %s, level: %s, rate: %s, subLabels: %s" % (label, level, rate, subLabels))
                if action == 0:
                    print("#图片机器检测结果: 最高等级为\"正常\"\n")
                elif action == 1:
                    print("#图片机器检测结果: 最高等级为\"嫌疑\"\n")
                elif action == 2:
                    print("#图片机器检测结果: 最高等级为\"确定\"\n")
            else:
                # status对应失败状态码:610:图片下载失败,620:图片格式错误,630:其它
                print("图片检测失败, taskId: %s, status: %s, name: %s" % (taskId, status, name))
        # 图片OCR结果
        ocrArray: list = ret["ocr"]
        for ocrResult in ocrArray:
            name: str = ocrResult["name"]
            taskId: str = ocrResult["taskId"]
            details: list = ocrResult["details"]
            print("taskId: %s, name: %s" % (taskId, name))
            # 产品需根据自身需求,自行解析处理,本示例只是简单输出ocr结果信息
            for detail in details:
                content: str = detail["content"]
                lineContents: list = detail["lineContents"]
                print("识别ocr文本内容: %s, ocr片段及坐标信息: %s" % (content, lineContents))
        # 图片人脸检测结果
        faceArray: list = ret["face"]
        for faceResult in faceArray:
            name: str = faceResult["name"]
            taskId: str = faceResult["taskId"]
            details: list = faceResult["details"]
            print("taskId: %s, name: %s" % (taskId, name))
            # 产品需根据自身需求,自行解析处理,本示例只是简单输出人脸结果信息
            for detail in details:
                faceNumber: int = detail["faceNumber"]
                faceContents: list = detail["faceContents"]
                print("识别人脸数量: %s, 人物信息及坐标信息: %s" % (faceNumber, faceContents))

    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", "http://as.dun.163.com/v4/image/check");
/** api version */
define("VERSION", "v4");
/** API timeout*/
define("API_TIMEOUT", 10);
require("../util.php");

/**
 * 反垃圾请求接口简单封装
 * $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);

    $result = curl_post($params, API_URL, API_TIMEOUT);
	// 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";
	$images = array();
	array_push($images, array(// type=1表示传图片url检查
		"name" => "https://nos.netease.com/yidun/2-0-0-a6133509763d4d6eac881a58f1791976.jpg",
		"type" => 1,
		"data" => "https://nos.netease.com/yidun/2-0-0-a6133509763d4d6eac881a58f1791976.jpg",
	));
	array_push($images, array( // type=2表示传图片base64编码进行检查
		"name" => "{\"imageId\": 33451123, \"contentId\": 78978}",
		"type" => 2,
		"data" => "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAYNElEQVR4nO2dP3vivNKHnfc6FWmhZVvTAk9JvkPSLikfsvUpSZ18hpAtl7TJdyBlYFvThpa0UK7fwtf6OP4zM/ZIlk1+d5HLOytpRsbjGVmyfBaGoQcAcMf/uTYAgK8OnBAAx8AJAXAMnBAAx8AJAXAMnBAAx8AJAXAMnBAAx8AJAXBNSOLauvpYLBb0qWBZr9c12Pnw8FCDnUoVEhaLRQ2nqyHQpwKREADHwAkBcAycUErYkuS8LXaCGDghAI6BE0o5OztzbYKIttgJYuCEUtqS5rXFThADJwTAMXBCABwDJwTAMXBCKW154NEWO0HMf5T1f/365fu+EVOscn19vd1urarwff/t7U3ZCGvn/f39z58/NSoOh4OmesR0OqXtnM/nV1dXGhW+7//69UvTQj1st9vr62tNC1on9H1/NBpFd98wDM/OzpJ/ozL653VRgxrh+fk5qyW2PLdNNsKcn5+Px2NWC02n06EL7Ha73W6n1KInCILfv38TBT4+PpQqOp2O/nzWgD710Dqhl7juUx4YX81Jb0y6aylhblflQmFHNG1KHBWALBgTAuAYA5EwFbXodDQ+LiXUp6PyjlRORxEGQTWQjqYrIh0FNYNImO4IIiGoGUTCdEVEQlAziITpjiASgppBJExXRCQENYMpCgAcYyAS0jw9Pb2+vtrW0oStu3a73f39vb4RusD3798nk4lShd7O29vb/X5PFFAaKeTm5sa2islkMp1O7erI3YMthq3+9vb258+fqHB0kPwbhuFsNrPbAc/zPO/PXyLVKcIwHI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FHihTtdjvturaQhK2OLQ/NbnkoUUQL2S8KS9Bvzaj/Uq/+C7gS2OtzNpvZthPpKACOgRMC4JhTc0LnUxSS9jVTFOHf0QgxnaBHaCdBWGk6IVdoVZEcpZ0Ep+aEuSel2i+aEgqnKCTt51ZP/cZFJSMziqobuSbkdhJUm06wOsegnHhQ2klwak4IQOs4NSdEOiq0xIidBEhH5ZyaEyIdFVpixE4CpKNyTs0JAWgdcEIAHGN92dpkMomPw7yVStn/ZUsS2BsTBkHw+vpK1H1/fxe2nzuKI7Kd5N/VakVvH0Yb6Xlet9ul9xeT20mQyq6zv2Z8Pot+d3pZXMTj4yN92VxeXna73az2+Dh5feYSFyhSxBrJE5Kw1dlla0mS67+I/w0zK8XY8qxQv2ytnuVgyV7nltQvAxwOh0Xa5UL9srV4ZalV1us1bYYeLFsDoPXU6oR0SlOUjxXNASiFtIXVqgvb10xRGLeENcn2FIVtaO0GhZWp1Qlp04s6GUGXryCkLaxWXdh+yD36TwlTJc1awppE2ElgY5KgGsoJElNTKQRIRwFwDJwQAMdgTGiyurB9jAk9o0m+0BKMCT0PY0KMCTEmzAPpKACOQTpqsrqwfaSjntH8QmhJY9NR7bK17XZbW16h4XA4SIqF3Ho6JZvNRtnCfr83YkmYeCHj7O8bUnIh274+eet0Or7vl+pUFnYtYb/fjz+lWC1IKC309E54fX2tN+LroPzI7inBXr6+7+vvWaPRiP6m6mKxoFcC1hBjMCYEwDFwwk/YHhM2hxaNCa0O1ZowJoQTfsL2FEVzaNEUhdWZA0xRAADghJ9BOioUsiAdlQMn/ATSUaGQBemoHDghAI6BEwLgGDjhJzAmFApZMCaUAyf8BMaEQiELxoRyzk7yCgOgRSASAuAYOCEAjoETAuAYOCEAjoETAuAYOCEAjoETAuAYOCEAjoETAuCY/wc8SC3r28PmnQAAAABJRU5ErkJggg=="
	));
	$params = array(
		"images"=>json_encode($images)
		// "account"=>"php@163.com",
		// "ip"=>"123.115.77.137",
	);
	var_dump($params);

	$ret = check($params);
	var_dump($ret);
	if ($ret["code"] == 200) {
		$antispamArray = $ret["antispam"];
		foreach($antispamArray as $index => $image_ret){
		    $name = $image_ret["name"];
		    $taskId = $image_ret["taskId"];
		    $status = $image_ret["status"];
		    if($status==0){
		        $action = $image_ret["action"];
                $labelArray = $image_ret["labels"];
                echo "taskId={$taskId},name={$name},action={$action}\n";
                foreach($labelArray as $index=>$label){
                    // subLabels为二级分类数组,根据需要解析
                    $subLabels = $label["subLabels"];
                    echo "label:{$label["label"]}, level={$label["level"]}, rate={$label["rate"]}\n";
                }
                if($action==0){
                    echo "#图片机器检测结果:最高等级为:正常\n";
                }else if($action==1){
                    echo "#图片机器检测结果:最高等级为:嫌疑\n";
                }else if($action==2){
                    echo "#图片机器检测结果:最高等级为:确定\n";
                }
		    } else {
                // status对应失败状态码:610:图片下载失败,620:图片格式错误,630:其它
                echo "图片检测失败,taskId:{$taskId}, status={$status}, name={$name}\n";
		    }
		}
		// 图片OCR结果
		$ocrArray = $ret["ocr"];
        foreach($ocrArray as $index => $ocr){
            $name = $ocr["name"];
            $taskId = $ocr["taskId"];
            $detailArray = $ocr["details"];
            echo "taskId={$taskId},name={$name}\n";
            // 产品需根据自身需求,自行解析处理,本示例只是简单输出ocr结果信息
            foreach($detailArray as $index=>$detail){
                // 识别ocr文本内容
                $content = $detail["content"];
                // ocr片段及坐标信息
                $lineContents = $detail["lineContents"];
            }
        }
        // 图片人脸检测结果
        $faceArray = $ret["face"];
        foreach($faceArray as $index => $face){
            $name = $face["name"];
            $taskId = $face["taskId"];
            $detailArray = $face["details"];
            echo "taskId={$taskId},name={$name}\n";
            // 产品需根据自身需求,自行解析处理,本示例只是简单输出人脸结果信息
            foreach($detailArray as $index=>$detail){
                // 识别人脸数量
                $faceNumber = $detail["faceNumber"];
                // 人物信息及坐标信息
                $faceContents = $detail["faceContents"];
            }
        }
        // 图片质量检测结果
        $qualityArray = $ret["quality"];
        foreach($qualityArray as $index => $quality){
            $name = $quality["name"];
            $taskId = $quality["taskId"];
            $detailArray = $quality["details"];
            echo "taskId={$taskId},name={$name}\n";
            // 产品需根据自身需求,自行解析处理,本示例只是简单输出质量结果信息
            foreach($detailArray as $index=>$detail){
                // 图片美观度分数
                $aestheticsRate = $detail["aestheticsRate"];
                // 图片基本信息
                $metaInfo = $detail["metaInfo"];
                // 图片边框信息
                $boarderInfo = $detail["boarderInfo"];
            }
        }
    }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 ImageCheckApiDemo
    {
        public static void imageCheck()
        {
            /** 产品密钥ID,产品标识 */
            String secretId = "your_secret_id";
            /** 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露 */
            String secretKey = "your_secret_key";
            /** 业务ID,易盾根据产品业务特点分配 */
            String businessId = "your_business_id";
            /** 易盾内容安全服务图片在线检测接口地址 */
            String apiUrl = "http://as.dun.163.com/v4/image/check";
            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", "v4");
            parameters.Add("timestamp", time);
            parameters.Add("nonce", new Random().Next().ToString());

            // 2.设置私有参数
            JArray jarray = new JArray();
            JObject image1 = new JObject();
            image1.Add("name", "http://p1.music.126.net/lEQvXzoC17AFKa6yrf-ldA==/1412872446212751.jpg");
            image1.Add("type", 1);
            image1.Add("data", "http://p1.music.126.net/lEQvXzoC17AFKa6yrf-ldA==/1412872446212751.jpg");
            jarray.Add(image1);

            JObject image2 = new JObject();
            image2.Add("name", "{\"imageId\": 33451123, \"contentId\": 78978}");
            image2.Add("type", 2);
            image2.Add("data", "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAYNElEQVR4nO2dP3vivNKHn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8Pot+d3pZXMTj4yN92VxeXna73az2+Dh5feYSFyhSxBrJE5Kw1dlla0mS67+I/w0zK8XY8qxQv2ytnuVgyV7nltQvAxwOh0Xa5UL9srV4ZalV1us1bYYeLFsDoPXU6oR0SlOUjxXNASiFtIXVqgvb10xRGLeENcn2FIVtaO0GhZWp1Qlp04s6GUGXryCkLaxWXdh+yD36TwlTJc1awppE2ElgY5KgGsoJElNTKQRIRwFwDJwQAMdgTGiyurB9jAk9o0m+0BKMCT0PY0KMCTEmzAPpKACOQTpqsrqwfaSjntH8QmhJY9NR7bK17XZbW16h4XA4SIqF3Ho6JZvNRtnCfr83YkmYeCHj7O8bUnIh274+eet0Or7vl+pUFnYtYb/fjz+lWC1IKC309E54fX2tN+LroPzI7inBXr6+7+vvWaPRiP6m6mKxoFcC1hBjMCYEwDFwwk/YHhM2hxaNCa0O1ZowJoQTfsL2FEVzaNEUhdWZA0xRAADghJ9BOioUsiAdlQMn/ATSUaGQBemoHDghAI6BEwLgGDjhJzAmFApZMCaUAyf8BMaEQiELxoRyzk7yCgOgRSASAuAYOCEAjoETAuAYOCEAjoETAuAYOCEAjoETAuAYOCEAjoETAuCY/wc8SC3r28PmnQAAAABJRU5ErkJggg==");
            jarray.Add(image2);

            parameters.Add("images", jarray.ToString());
            // parameters.Add("account", "csharp@163.com");
            // parameters.Add("ip", "123.115.77.137");

            // 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)
                {
                    JArray array = (JArray)ret.SelectToken("antispam");
                    foreach (var item in array)
                    {
                        JObject tmp = (JObject)item;
                        String name = tmp.GetValue("name").ToObject<String>();
                        String taskId = tmp.GetValue("taskId").ToObject<String>();
                        JArray labels = (JArray)tmp.SelectToken("labels");
                        Console.WriteLine(String.Format("taskId={0},name={1},labels:", taskId, name));
                        int maxLevel = -1;
                        // 产品需根据自身需求,自行解析处理,本示例只是简单判断分类级别
                        foreach (var lable in labels)
                        {
                            JObject lableData = (JObject)lable;
                            int label = lableData.GetValue("label").ToObject<Int32>();
                            int level = lableData.GetValue("level").ToObject<Int32>();
                            double rate = lableData.GetValue("rate").ToObject<Double>();
                            Console.WriteLine(String.Format("label:{0}, level={1}, rate={2}", label, level, rate));
                            maxLevel = level > maxLevel ? level : maxLevel;
                        }

                        switch (maxLevel) {
                            case 0:
                                Console.WriteLine("#图片机器检测结果:最高等级为\"正常\"\n");
                                break;
                            case 1:
                                 Console.WriteLine("#图片机器检测结果:最高等级为\"嫌疑\"\n");
                                break;
                            case 2:
                                Console.WriteLine("#图片机器检测结果:最高等级为\"确定\"\n");
                                break;
                            default:
                                break;
                        }
                    }
                }
                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="http://as.dun.163.com/v4/image/check";
//请求参数
var post_data = {
    // 1.设置公有有参数
    secretId:secretId,
    businessId:businessId,
    version:"v4",
    timestamp:new Date().getTime(),
    nonce:utils.noncer()
    // 2.1设置私有参数
    // account:"nodejs@163.com",
    // ip:"123.115.77.137"
};
// 2.2请求图片参数
var images=[{
        name:"http://p1.music.126.net/lEQvXzoC17AFKa6yrf-ldA==/1412872446212751.jpg",
        type:1,
        data:"http://p1.music.126.net/lEQvXzoC17AFKa6yrf-ldA==/1412872446212751.jpg"
    },{
        name:"{\"imageId\": 33451123, \"contentId\": 78978}",
        type:2,
        data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sS2BsTBkHw+vpK1H1/fxe2nzuKI7Kd5N/VakVvH0Yb6Xlet9ul9xeT20mQyq6zv2Z8Pot+d3pZXMTj4yN92VxeXna73az2+Dh5feYSFyhSxBrJE5Kw1dlla0mS67+I/w0zK8XY8qxQv2ytnuVgyV7nltQvAxwOh0Xa5UL9srV4ZalV1us1bYYeLFsDoPXU6oR0SlOUjxXNASiFtIXVqgvb10xRGLeENcn2FIVtaO0GhZWp1Qlp04s6GUGXryCkLaxWXdh+yD36TwlTJc1awppE2ElgY5KgGsoJElNTKQRIRwFwDJwQAMdgTGiyurB9jAk9o0m+0BKMCT0PY0KMCTEmzAPpKACOQTpqsrqwfaSjntH8QmhJY9NR7bK17XZbW16h4XA4SIqF3Ho6JZvNRtnCfr83YkmYeCHj7O8bUnIh274+eet0Or7vl+pUFnYtYb/fjz+lWC1IKC309E54fX2tN+LroPzI7inBXr6+7+vvWaPRiP6m6mKxoFcC1hBjMCYEwDFwwk/YHhM2hxaNCa0O1ZowJoQTfsL2FEVzaNEUhdWZA0xRAADghJ9BOioUsiAdlQMn/ATSUaGQBemoHDghAI6BEwLgGDjhJzAmFApZMCaUAyf8BMaEQiELxoRyzk7yCgOgRSASAuAYOCEAjoETAuAYOCEAjoETAuAYOCEAjoETAuAYOCEAjoETAuCY/wc8SC3r28PmnQAAAABJRU5ErkJggg=="
    }];
post_data.images=JSON.stringify(images);
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.antispam;
        for(var i=0;i<result.length;i++){
            var obj=result[i];
            var name=obj.name;
            var taskId=obj.taskId;
            var labelsArray=obj.labels;
            console.log("taskId="+taskId+",name="+name+",labels:");
            var  maxLevel = -1;
            // 产品需根据自身需求,自行解析处理,本示例只是简单判断分类级别
            for(var k=0;k<labelsArray.length;k++){
                var labelObj=labelsArray[k];
                var label=labelObj.label;
                var level=labelObj.level;
                var rate=labelObj.rate;
                console.log("lable:"+label+",level:"+level+",rate:"+rate);
                maxLevel = level > maxLevel ? level : maxLevel;
            }
             switch (maxLevel) {
            case 0:
                console.log("#图片机器检测结果:最高等级为\"正常\"\n");
                break;
            case 1:
                console.log("#图片机器检测结果:最高等级为\"嫌疑\"\n");
                break;
            case 2:
                console.log("#图片机器检测结果:最高等级为\"确定\"\n");
                break;
            default:
                break;
                }

        }
    }else{
         console.log('ERROR:code=' + code+',msg='+msg);
    }

}
utils.sendHttpRequest(apiurl,"POST",post_data,responseCallback);
/*
@Author : yidun_dev
@Date : 2020-01-20
@File : image_check.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     = "http://as.dun.163.com/v4/image/query"
	version    = "v4"
	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() {
	var images []map[string]string
	imageUrl := map[string]string{
		"name": "https://nos.netease.com/yidun/2-0-0-a6133509763d4d6eac881a58f1791976.jpg",
		"type": "1",
		"data": "https://nos.netease.com/yidun/2-0-0-a6133509763d4d6eac881a58f1791976.jpg",
		//"callbackUrl": "http://***",  //主动回调地址url, 如果设置了则走主动回调逻辑
	}
	imageBase64 := map[string]string{
		"name": "{\"imageId\": 33451123, \"contentId\": 78978}",
		"type": "2",
		"data": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAYNElEQVR4nO2dP3vivNKHnfc6FWmhZVvTAk9JvkPSLikfsvUpSZ18hpAtl7TJdyBlYFvThpa0UK7fwtf6OP4zM/ZIlk1+d5HLOytpRsbjGVmyfBaGoQcAcMf/uTYAgK8OnBAAx8AJAXAMnBAAx8AJAXAMnBAAx8AJAXAMnBAAx8AJAXBNSOLauvpYLBb0qWBZr9c12Pnw8FCDnUoVEhaLRQ2nqyHQpwKREADHwAkBcAycUErYkuS8LXaCGDghAI6BE0o5OztzbYKIttgJYuCEUtqS5rXFThADJwTAMXBCABwDJwTAMXBCKW154NEWO0HMf5T1f/365fu+EVOscn19vd1urarwff/t7U3ZCGvn/f39z58/NSoOh4OmesR0OqXtnM/nV1dXGhW+7//69UvTQj1st9vr62tNC1on9H1/NBpFd98wDM/OzpJ/ozL653VRgxrh+fk5qyW2PLdNNsKcn5+Px2NWC02n06EL7Ha73W6n1KInCILfv38TBT4+PpQqOp2O/nzWgD710Dqhl7juUx4YX81Jb0y6aylhblflQmFHNG1KHBWALBgTAuAYA5EwFbXodDQ+LiXUp6PyjlRORxEGQTWQjqYrIh0FNYNImO4IIiGoGUTCdEVEQlAzi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AuAYOCEAjoETAuAYOCEAjoETAuCY/wc8SC3r28PmnQAAAABJRU5ErkJggg==",
		//"callbackUrl": "http://***",  //主动回调地址url, 如果设置了则走主动回调逻辑
	}
	images = append(images, imageUrl, imageBase64)
	jsonString, _ := json.Marshal(images)
	params := url.Values{
		"images":  []string{string(jsonString)},
		"account": []string{"python@163.com"},
		"ip":      []string{"123.115.77.137"},
	}

	ret := check(params)

	code, _ := ret.Get("code").Int()
	message, _ := ret.Get("msg").String()
	if code == 200 {
		antispamArray, _ := ret.Get("antispam").Array()
		for _, antispamResult := range antispamArray {
			if antispamMap, ok := antispamResult.(map[string]interface{}); ok {
				name := antispamMap["name"].(string)
				taskId := antispamMap["taskId"].(string)
				status, _ := antispamMap["status"].(json.Number).Int64()
				//图片检测状态码,定义为:0:检测成功,610:图片下载失败,620:图片格式错误,630:其它
				if status == 0 {
					//图片维度结果
					action, _ := antispamMap["action"].(json.Number).Int64()
					labelArray := antispamMap["labels"].([]interface{})
					fmt.Printf("taskId: %s, status: %d, name: %s, action: %d", taskId, status, name, action)
					//产品需根据自身需求,自行解析处理,本示例只是简单判断分类级别
					for _, labelItem := range labelArray {
						if labelItemMap, ok := labelItem.(map[string]interface{}); ok {
							label, _ := labelItemMap["label"].(json.Number).Int64()
							level, _ := labelItemMap["level"].(json.Number).Int64()
							rate := labelItemMap["rate"].(float64)
							subLabels := labelItemMap["subLabels"].([]interface{})
							fmt.Printf("label: %d, level: %d, rate: %f, subLabels: %s", label, level, rate, subLabels)
						}
					}
					if action == 0 {
						fmt.Printf("#图片机器检测结果: 最高等级为\"正常\"\n")
					} else if action == 1 {
						fmt.Printf("#图片机器检测结果: 最高等级为\"嫌疑\"\n")
					} else if action == 2 {
						fmt.Printf("#图片机器检测结果: 最高等级为\"确定\"\n")
					}
				} else {
					//status对应失败状态码:610:图片下载失败,620:图片格式错误,630:其它
					fmt.Printf("图片检测失败, taskId: %s, status: %d, name: %s", taskId, status, name)
				}
			}
		}
		ocrArray, _ := ret.Get("ocr").Array()
		for _, ocrResult := range ocrArray {
			if ocrMap, ok := ocrResult.(map[string]interface{}); ok {
				name := ocrMap["name"].(string)
				taskId := ocrMap["taskId"].(string)
				details := ocrMap["details"].([]interface{})
				fmt.Printf("taskId: %s, name: %s", taskId, name)
				//产品需根据自身需求,自行解析处理,本示例只是简单输出ocr结果信息
				for _, detail := range details {
					if detailMap, ok := detail.(map[string]interface{}); ok {
						content := detailMap["content"].(string)
						lineContents := detailMap["lineContents"]
						fmt.Printf("识别ocr文本内容: %s, ocr片段及坐标信息: %s", content, lineContents)
					}
				}
			}
		}
		faceArray, _ := ret.Get("face").Array()
		for _, faceResult := range faceArray {
			if faceMap, ok := faceResult.(map[string]interface{}); ok {
				name := faceMap["name"].(string)
				taskId := faceMap["taskId"].(string)
				details := faceMap["details"].([]interface{})
				fmt.Printf("taskId: %s, name: %s", taskId, name)
				//产品需根据自身需求,自行解析处理,本示例只是简单输出人脸结果信息
				for _, detail := range details {
					if detailMap, ok := detail.(map[string]interface{}); ok {
						faceNumber := detailMap["faceNumber"].(string)
						faceContents := detailMap["faceContents"]
						fmt.Printf("识别人脸数量: %s, 人物信息及坐标信息: %s", faceNumber, faceContents)
					}
				}
			}
		}
	} else {
		fmt.Printf("ERROR: code=%d, msg=%s", code, message)
	}
}

响应示例

输出结果:

注:分类信息,100:色情,110:性感,200:广告,210:二维码,300:暴恐,400:违禁,500:涉政

{
	"code": 200,
	"msg": "ok",
	"antispam": [{
		"taskId": "2930cd4b13464676a0779ef09706e700",
		"status": 0,
		"action": 2,
		"name": "1234",
		"labels": [{
			"label": 500,
			"level": 2,
			"rate": 1.0,
			"subLabels": [{
				"subLabel": 50003,
				"rate": 1.0,
				"details": {
					"hitInfos": ["XXX"]
				}
			}]
		}, {
			"label": 200,
			"level": 1,
			"rate": 1.0,
			"subLabels": []
		}, {
			"label": 100,
			"level": 0,
			"rate": 0.9999522,
			"subLabels": []
		}, {
			"label": 110,
			"level": 0,
			"rate": 0.9999522,
			"subLabels": []
		}, {
			"label": 210,
			"level": 0,
			"rate": 1.0,
			"subLabels": []
		}, {
			"label": 300,
			"level": 0,
			"rate": 0.9642776,
			"subLabels": []
		}, {
			"label": 400,
			"level": 0,
			"rate": 1.0,
			"subLabels": []
		}]
	}, {
		"taskId": "0f6260acdb7647e281e41874189206e9",
		"status": 0,
		"action": 2,
		"name": "1234",
		"labels": [{
			"label": 500,
			"level": 2,
			"rate": 1.0,
			"subLabels": [{
				"subLabel": 50003,
				"rate": 1.0,
				"details": {
					"hitInfos": ["XXX"]
				}
			}]
		}, {
			"label": 200,
			"level": 1,
			"rate": 1.0,
			"subLabels": []
		}, {
			"label": 100,
			"level": 0,
			"rate": 0.9999522,
			"subLabels": []
		}, {
			"label": 110,
			"level": 0,
			"rate": 0.9999522,
			"subLabels": []
		}, {
			"label": 210,
			"level": 0,
			"rate": 1.0,
			"subLabels": []
		}, {
			"label": 300,
			"level": 0,
			"rate": 0.92121917,
			"subLabels": []
		}, {
			"label": 400,
			"level": 0,
			"rate": 1.0,
			"subLabels": []
		}]
	}],
	"ocr": [{
		"taskId": "2930cd4b13464676a0779ef09706e700",
		"name": "1234",
		"details": [{
			"content": "直播CCTV1综合",
	   "background": "complex",
			"lineContents": [{
				"lineContent": "直播",
				"polygon": [0.7745177268981933, 0.09276469945907592, 0.8768445968627929, 0.0939750075340271, 0.8766385078430176, 0.1636715531349182, 0.7743116855621338, 0.16246124505996704]
			}, {
				"lineContent": "CCTV1",
				"polygon": [0.12932851314544677, 0.09998217821121216, 0.23668222427368163, 0.10091289281845092, 0.2365492343902588, 0.16227685213088988, 0.12919551134109497, 0.16134613752365112]
			}, {
				"lineContent": "综合",
				"polygon": [0.14835870265960693, 0.15775651931762696, 0.23298816680908202, 0.15898795127868653, 0.23278720378875734, 0.21423439979553222, 0.14815772771835328, 0.21300296783447265]
			}]
		}]
	}, {
		"taskId": "0f6260acdb7647e281e41874189206e9",
		"name": "1234",
		"details": [{
			"content": "直播CCTV1综合",
	   "background": "complex",
			"lineContents": [{
				"lineContent": "直播",
				"polygon": [0.7745157241821289, 0.09276466369628907, 0.8768444061279297, 0.09396190643310547, 0.876640510559082, 0.1636584758758545, 0.7743117809295654, 0.1624612331390381]
			}, {
				"lineContent": "CCTV1",
				"polygon": [0.1293278932571411, 0.0999821662902832, 0.23668241500854492, 0.100907301902771, 0.2365502119064331, 0.16227684020996094, 0.1291956901550293, 0.16135170459747314]
			}, {
				"lineContent": "综合",
				"polygon": [0.14835870265960693, 0.15775651931762696, 0.23298816680908202, 0.15898795127868653, 0.23278720378875734, 0.21423439979553222, 0.14815772771835328, 0.21300296783447265]
			}]
		}]
	}]

	"face": [{
		"taskId": "57132814c2a24350a337d0a76dd49bbf",
		"name": "xxxx",
		"details": [{
			"faceNumber": 1,
			"faceContents": [{
				"name": "XXXX",
				"x1": 0.41362658,
				"y1": 0.18348134,
				"x2": 0.50894177,
				"y2": 0.37411177
			}]
		}]
	}]
	
	}