API | 操作描述 |
用于提交一个文档审核任务 | |
用于查询指定的文档审核任务 |
using COSXML.Model.CI;using COSXML.Auth;using System;using System.Threading;using COSXML;namespace COSSnippet{public class SubmitDocumentCensorJobModel {private CosXml cosXml;SubmitDocumentCensorJobModel() {CosXmlConfig config = new CosXmlConfig.Builder().SetRegion("COS_REGION") // 设置默认的地域, COS 地域的简称请参照 https://www.tencentcloud.com/document/product/436/6224?from_cn_redirect=1.Build();string secretId = "SECRET_ID"; // 云 API 密钥 SecretId, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capistring secretKey = "SECRET_KEY"; // 云 API 密钥 SecretKey, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capilong durationSecond = 600; //每次请求签名有效时长,单位为秒QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,secretKey, durationSecond);this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);}/// 提交文档审核任务public string SubmitDocumentCensorJob(){// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000"; // 注意:此操作需要 bucket 开通内容审核相关功能SubmitDocumentCensorJobRequest request = new SubmitDocumentCensorJobRequest(bucket);request.SetUrl("url"); // 审核文档的URL,需要替换成具体需要审核的文档URL// 审核的场景类型,有效值:Porn(涉黄)、Ads(广告),可以传入多种类型,不同类型以逗号分隔,例如:Porn,Adsrequest.SetDetectType("Porn,Ads");// 执行请求SubmitCensorJobResult result = cosXml.SubmitDocumentCensorJob(request);Console.WriteLine(result.GetResultInfo());Console.WriteLine(result.censorJobsResponse.JobsDetail.JobId);Console.WriteLine(result.censorJobsResponse.JobsDetail.State);Console.WriteLine(result.censorJobsResponse.JobsDetail.CreationTime);return result.censorJobsResponse.JobsDetail.JobId;}static void Main(string[] args){SubmitDocumentCensorJobModel m = new SubmitDocumentCensorJobModel();/// 提交审核任务string JobId = m.SubmitDocumentCensorJob();}}}
using COSXML.Model.CI;using COSXML.Auth;using System;using System.Threading;using COSXML;namespace COSSnippet{public class SubmitDocumentCensorJobModel {private CosXml cosXml;SubmitDocumentCensorJobModel() {CosXmlConfig config = new CosXmlConfig.Builder().SetRegion("COS_REGION") // 设置默认的地域, COS 地域的简称请参照 https://www.tencentcloud.com/document/product/436/6224?from_cn_redirect=1.Build();string secretId = "SECRET_ID"; // 云 API 密钥 SecretId, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capistring secretKey = "SECRET_KEY"; // 云 API 密钥 SecretKey, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capilong durationSecond = 600; //每次请求签名有效时长,单位为秒QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,secretKey, durationSecond);this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);}/// 查询文档审核任务结果public void GetDocumentCensorJobResult(string JobId){// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000"; // 注意:此操作需要 bucket 开通内容审核相关功能GetDocumentCensorJobRequest request = new GetDocumentCensorJobRequest(bucket, JobId);// 执行请求GetDocumentCensorJobResult result = cosXml.GetDocumentCensorJob(request);Console.WriteLine(result.GetResultInfo());// 读取审核结果Console.WriteLine(result.resultStruct.JobsDetail.State);Console.WriteLine(result.resultStruct.JobsDetail.JobId);Console.WriteLine(result.resultStruct.JobsDetail.Suggestion);Console.WriteLine(result.resultStruct.JobsDetail.CreationTime);Console.WriteLine(result.resultStruct.JobsDetail.Url);Console.WriteLine(result.resultStruct.JobsDetail.PageCount);Console.WriteLine(result.resultStruct.JobsDetail.Labels);Console.WriteLine(result.resultStruct.JobsDetail.Labels.PornInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.Labels.PornInfo.Score);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.Url);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.Text);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.PageNumber);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.PornInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.PornInfo.SubLabel);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.PornInfo.Score);}static void Main(string[] args){SubmitDocumentCensorJobModel m = new SubmitDocumentCensorJobModel();/// 输入提交审核任务时返回的, 唯一标识此次审核任务的 JobIdstring JobId = "xxx";/// 查询审核任务结果m.GetDocumentCensorJobResult(JobId);}}}
本页内容是否解决了您的问题?