文檔審核增強(qiáng)版SDK及接入指南
文檔審核增強(qiáng)版支持SDK方式調(diào)用和原生HTTPS方式調(diào)用。推薦您使用SDK接入,可免去簽名驗(yàn)證以及Body格式構(gòu)建等細(xì)節(jié)步驟。本文介紹文檔審核增強(qiáng)版接入的方式。
步驟一:開通服務(wù)
訪問開通內(nèi)容審核增強(qiáng)版服務(wù)頁面,開通文檔審核增強(qiáng)版服務(wù)。接口接入使用后系統(tǒng)會按使用量自動出賬,具體信息,請參見計(jì)費(fèi)說明。您也可以購買按量抵扣資源包,資源包相較于后付費(fèi)存在一定階梯折扣,適合使用量級可預(yù)期和較大的用戶。
開通文檔審核增強(qiáng)版服務(wù)后,默認(rèn)付費(fèi)方式是按量后付費(fèi),且按照實(shí)際用量結(jié)算當(dāng)日費(fèi)用,不調(diào)用服務(wù)不收費(fèi)。
步驟二:為RAM用戶授權(quán)
在接入SDK或者API之前,您需要為RAM用戶授權(quán)。您可以為RAM用戶創(chuàng)建一個訪問密鑰(AccessKey)。在調(diào)用阿里云API時您需要使用AccessKey完成身份驗(yàn)證。獲取方式,請參見獲取AccessKey。
使用RAM管理員登錄RAM控制臺。
- 創(chuàng)建RAM用戶。
具體操作,請參見創(chuàng)建RAM用戶。
- 向RAM用戶授權(quán)系統(tǒng)策略權(quán)限:
AliyunYundunGreenWebFullAccess
。具體操作,請參見為RAM用戶授權(quán)。
完成以上配置后,您可以使用RAM用戶調(diào)用內(nèi)容安全API。
步驟三:安裝并接入文檔審核服務(wù)
目前支持的接入地域?yàn)椋?/p>
地域 | 外網(wǎng)接入地址 | 內(nèi)網(wǎng)接入地址 | 支持的服務(wù) |
華東2(上海) | green-cip.cn-shanghai.aliyuncs.com | green-cip-vpc.cn-shanghai.aliyuncs.com | document_detection |
華北2(北京) | green-cip.cn-beijing.aliyuncs.com | green-cip-vpc.cn-beijing.aliyuncs.com | |
華東1(杭州) | green-cip.cn-hangzhou.aliyuncs.com | green-cip-vpc.cn-hangzhou.aliyuncs.com | |
華南1(深圳) | green-cip.cn-shenzhen.aliyuncs.com | green-cip-vpc.cn-shenzhen.aliyuncs.com |
如果需要其他語言的SDK示例代碼,您可以通過OpenAPI 開發(fā)者門戶在線調(diào)試工具調(diào)試API接口,該工具會自動生成相應(yīng)API的SDK調(diào)用示例代碼。
阿里云SDK代碼通過定義ALIBABA_CLOUD_ACCESS_KEY_ID
和ALIBABA_CLOUD_ACCESS_KEY_SECRET
環(huán)境變量來創(chuàng)建默認(rèn)的訪問憑證。調(diào)用接口時,程序直接訪問憑證,讀取您的訪問密鑰(即AccessKey)并自動完成鑒權(quán)。您在接入SDK代碼示例之前,請先配置環(huán)境變量。具體操作,請參見身份驗(yàn)證配置。
Java SDK
在pom.xml中加入相應(yīng)依賴,就可以在Maven工程中使用SDK。
在dependencies中添加如下依賴:
<dependency> <groupId>com.aliyun</groupId> <artifactId>green20220302</artifactId> <version>2.2.7</version> </dependency>
接入Java SDK。
提交文檔檢測任務(wù)代碼示例
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.aliyun.green20220302.Client; import com.aliyun.green20220302.models.FileModerationRequest; import com.aliyun.green20220302.models.FileModerationResponse; import com.aliyun.green20220302.models.FileModerationResponseBody; import com.aliyun.teaopenapi.models.Config; public class FileModerationDemo { public static void main(String[] args) throws Exception { Config config = new Config(); /** * 阿里云賬號AccessKey擁有所有API的訪問權(quán)限,建議您使用RAM用戶進(jìn)行API訪問或日常運(yùn)維。 * 常見獲取環(huán)境變量方式: * 方式一: * 獲取RAM用戶AccessKey ID:System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"); * 獲取RAM用戶AccessKey Secret:System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); * 方式二: * 獲取RAM用戶AccessKey ID:System.getProperty("ALIBABA_CLOUD_ACCESS_KEY_ID"); * 獲取RAM用戶AccessKey Secret:System.getProperty("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); */ config.setAccessKeyId("建議從環(huán)境變量中獲取RAM用戶AccessKey ID"); config.setAccessKeySecret("建議從環(huán)境變量中獲取RAM用戶AccessKey Secret"); //接入?yún)^(qū)域和地址請根據(jù)實(shí)際情況修改。 config.setRegionId("cn-shanghai"); config.setEndpoint("green-cip.cn-shanghai.aliyuncs.com"); //連接時超時時間,單位毫秒(ms)。 config.setReadTimeout(6000); //讀取時超時時間,單位毫秒(ms)。 config.setConnectTimeout(3000); Client client = new Client(config); JSONObject serviceParameters = new JSONObject(); serviceParameters.put("url", "https://xxx.oss.aliyuncs.com/xxx.pdf"); // 文件URL FileModerationRequest fileModerationRequest = new FileModerationRequest(); // 檢測類型:document_detection 通用文檔檢測 fileModerationRequest.setService("document_detection"); fileModerationRequest.setServiceParameters(serviceParameters.toJSONString()); try { FileModerationResponse response = client.fileModeration(fileModerationRequest); if (response.getStatusCode() == 200) { FileModerationResponseBody result = response.getBody(); System.out.println(JSON.toJSONString(result)); System.out.println("requestId = " + result.getRequestId()); System.out.println("code = " + result.getCode()); System.out.println("msg = " + result.getMessage()); Integer code = result.getCode(); if (200 == code) { FileModerationResponseBody.FileModerationResponseBodyData data = result.getData(); System.out.println("taskId = [" + data.getTaskId() + "]"); } else { System.out.println("file moderation not success. code:" + code); } } else { System.out.println("response not success. status:" + response.getStatusCode()); } } catch (Exception e) { e.printStackTrace(); } } }
獲取文檔檢測任務(wù)結(jié)果
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.aliyun.green20220302.Client; import com.aliyun.green20220302.models.DescribeFileModerationResultRequest; import com.aliyun.green20220302.models.DescribeFileModerationResultResponse; import com.aliyun.green20220302.models.DescribeFileModerationResultResponseBody; import com.aliyun.teaopenapi.models.Config; public class DescribeFileModerationResultDemo { public static void main(String[] args) throws Exception { Config config = new Config(); /** * 阿里云賬號AccessKey擁有所有API的訪問權(quán)限,建議您使用RAM用戶進(jìn)行API訪問或日常運(yùn)維。 * 常見獲取環(huán)境變量方式: * 方式一: * 獲取RAM用戶AccessKey ID:System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"); * 獲取RAM用戶AccessKey Secret:System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); * 方式二: * 獲取RAM用戶AccessKey ID:System.getProperty("ALIBABA_CLOUD_ACCESS_KEY_ID"); * 獲取RAM用戶AccessKey Secret:System.getProperty("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); */ config.setAccessKeyId("建議從環(huán)境變量中獲取RAM用戶AccessKey ID"); config.setAccessKeySecret("建議從環(huán)境變量中獲取RAM用戶AccessKey Secret"); //接入?yún)^(qū)域和地址請根據(jù)實(shí)際情況修改 config.setRegionId("cn-shanghai"); config.setEndpoint("green-cip.cn-shanghai.aliyuncs.com"); //連接時超時時間,單位毫秒(ms)。 config.setReadTimeout(6000); //讀取時超時時間,單位毫秒(ms)。 config.setConnectTimeout(3000); Client client = new Client(config); JSONObject serviceParameters = new JSONObject(); // 提交任務(wù)時返回的taskId serviceParameters.put("taskId", "fi_f_O5z5i*********-1xxp0V"); DescribeFileModerationResultRequest describeFileModerationResultRequest = new DescribeFileModerationResultRequest(); describeFileModerationResultRequest.setService("document_detection"); describeFileModerationResultRequest.setServiceParameters(serviceParameters.toJSONString()); try { DescribeFileModerationResultResponse response = client.describeFileModerationResult(describeFileModerationResultRequest); if (response.getStatusCode() == 200) { DescribeFileModerationResultResponseBody result = response.getBody(); System.out.println("requestId=" + result.getRequestId()); System.out.println("code=" + result.getCode()); System.out.println("msg=" + result.getMessage()); if (200 == result.getCode()) { DescribeFileModerationResultResponseBody.DescribeFileModerationResultResponseBodyData data = result.getData(); System.out.println("pageResult = " + JSON.toJSONString(data.getPageResult())); System.out.println("dataId = " + data.getDataId()); System.out.println("url = " + data.getUrl()); } else { System.out.println("file moderation result not success. code:" + result.getCode()); } } else { System.out.println("response not success. status:" + response.getStatusCode()); } } catch (Exception e) { e.printStackTrace(); } } }
Python SDK
支持Python 3.6及以上版本。
執(zhí)行如下命令安裝pip。
pip install alibabacloud_green20220302==2.2.7
接入Python SDK。
提交文檔檢測任務(wù)代碼示例
# coding=utf-8 # python version >= 3.6 from alibabacloud_green20220302.client import Client from alibabacloud_green20220302 import models from alibabacloud_tea_openapi.models import Config import json config = Config( # 阿里云賬號AccessKey擁有所有API的訪問權(quán)限,建議您使用RAM用戶進(jìn)行API訪問或日常運(yùn)維。 # 強(qiáng)烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導(dǎo)致AccessKey泄露,威脅您賬號下所有資源的安全。 # 常見獲取環(huán)境變量方式: # 獲取RAM用戶AccessKey ID:os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'] # 獲取RAM用戶AccessKey Secret:os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'] access_key_id='建議從環(huán)境變量中獲取RAM用戶AccessKey ID', access_key_secret='建議從環(huán)境變量中獲取RAM用戶AccessKey Secret', # 連接超時時間 單位毫秒(ms) connect_timeout=10000, # 讀超時時間 單位毫秒(ms) read_timeout=3000, region_id='cn-shanghai', endpoint='green-cip.cn-shanghai.aliyuncs.com' ) clt = Client(config) serviceParameters = { 'url': 'https://detect-obj.oss-cn-hangzhou.aliyuncs.com/sample/xxxx.pdf', } fileModerationRequest = models.FileModerationRequest( # 檢測類型 service='document_detection', service_parameters=json.dumps(serviceParameters) ) try: response = clt.file_moderation(fileModerationRequest) if response.status_code == 200: # 調(diào)用成功 result = response.body print('response success. result:{}'.format(result)) else: print('response not success. status:{} ,result:{}'.format(response.status_code, response)) except Exception as err: print(err)
獲取文檔檢測任務(wù)結(jié)果
# coding=utf-8 # python version >= 3.6 from alibabacloud_green20220302.client import Client from alibabacloud_green20220302 import models from alibabacloud_tea_openapi.models import Config import json config = Config( # 阿里云賬號AccessKey擁有所有API的訪問權(quán)限,建議您使用RAM用戶進(jìn)行API訪問或日常運(yùn)維。 # 強(qiáng)烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導(dǎo)致AccessKey泄露,威脅您賬號下所有資源的安全。 # 常見獲取環(huán)境變量方式: # 獲取RAM用戶AccessKey ID:os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'] # 獲取RAM用戶AccessKey Secret:os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'] access_key_id='建議從環(huán)境變量中獲取RAM用戶AccessKey ID', access_key_secret='建議從環(huán)境變量中獲取RAM用戶AccessKey Secret', # 連接超時時間 單位毫秒(ms) connect_timeout=10000, # 讀超時時間 單位毫秒(ms) read_timeout=3000, region_id='cn-shanghai', endpoint='green-cip.cn-shanghai.aliyuncs.com' ) clt = Client(config) # 提交任務(wù)時返回的taskId serviceParameters = { "taskId": 'fi_f_11w5THcb*******a-1xx7hH' } describeFileModerationResultRequest = models.DescribeFileModerationResultRequest( # 檢測類型 service='document_detection', service_parameters=json.dumps(serviceParameters) ) try: response = clt.describe_file_moderation_result(describeFileModerationResultRequest) if response.status_code == 200: # 調(diào)用成功 # 獲取審核結(jié)果 result = response.body print('response success. result:{}'.format(result)) else: print('response not success. status:{} ,result:{}'.format(response.status_code, response)) except Exception as err: print(err)
PHP SDK
支持PHP 5.6及以上版本。
執(zhí)行如下命令引入相關(guān)依賴。
composer require alibabacloud/green-20220302
接入PHP SDK。
提交文檔檢測任務(wù)代碼示例
<?php require('vendor/autoload.php'); use AlibabaCloud\SDK\Green\V20220302\Models\FileModerationRequest; use AlibabaCloud\Tea\Exception\TeaUnableRetryError; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions; use AlibabaCloud\SDK\Green\V20220302\Green; $config = new Config([ /** * 阿里云賬號AccessKey擁有所有API的訪問權(quán)限,建議您使用RAM用戶進(jìn)行API訪問或日常運(yùn)維。 * 強(qiáng)烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導(dǎo)致AccessKey泄露,威脅您賬號下所有資源的安全。 * 常見獲取環(huán)境變量方式: * 獲取RAM用戶AccessKey ID:getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"); * 獲取RAM用戶AccessKey Secret:getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); */ "accessKeyId" => '建議從環(huán)境變量中獲取RAM用戶AccessKey ID', "accessKeySecret" => '建議從環(huán)境變量中獲取RAM用戶AccessKey Secret', "endpoint" => "green-cip.cn-shanghai.aliyuncs.com", "regionId" => "cn-shanghai" ]); // 注意,此處實(shí)例化的client請盡可能重復(fù)使用,避免重復(fù)建立連接,提升檢測性能。 $client = new Green($config); $request = new FileModerationRequest(); $request->service = "document_detection"; $serviceParameters = array("url" => "https://xxx.oss.aliyuncs.com/xxx.pdf"); $request->serviceParameters = json_encode($serviceParameters); $runtime = new RuntimeOptions(); $runtime->readTimeout = 6000; $runtime->connectTimeout = 3000; try { $response = $client->fileModerationWithOptions($request, $runtime); print_r($response->body); if (200 != $response->statusCode) { print_r("response not success. code:" . $response->statusCode); return; } $body = $response->body; print_r("requestId = " . $body->requestId . "\n"); print_r("code = " . $body->code . "\n"); print_r("message = " . $body->message . "\n"); if (200 != $body->code) { print_r("file moderation not success. code:" . $body->code); } $data = $body->data; print_r("taskId = " . $data->taskId); } catch (TeaUnableRetryError $e) { var_dump($e->getMessage()); var_dump($e->getErrorInfo()); var_dump($e->getLastException()); var_dump($e->getLastRequest()); }
獲取文檔檢測任務(wù)結(jié)果
<?php require('vendor/autoload.php'); use AlibabaCloud\SDK\Green\V20220302\Models\DescribeFileModerationResultRequest; use AlibabaCloud\Tea\Exception\TeaUnableRetryError; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions; use AlibabaCloud\SDK\Green\V20220302\Green; $config = new Config([ /** * 阿里云賬號AccessKey擁有所有API的訪問權(quán)限,建議您使用RAM用戶進(jìn)行API訪問或日常運(yùn)維。 * 強(qiáng)烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導(dǎo)致AccessKey泄露,威脅您賬號下所有資源的安全。 * 常見獲取環(huán)境變量方式: * 獲取RAM用戶AccessKey ID:getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"); * 獲取RAM用戶AccessKey Secret:getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); */ "accessKeyId" => '建議從環(huán)境變量中獲取RAM用戶AccessKey ID', "accessKeySecret" => '建議從環(huán)境變量中獲取RAM用戶AccessKey Secret', "endpoint" => "green-cip.cn-shanghai.aliyuncs.com", "regionId" => "cn-shanghai" ]); // 注意,此處實(shí)例化的client請盡可能重復(fù)使用,避免重復(fù)建立連接,提升檢測性能。 $client = new Green($config); $request = new DescribeFileModerationResultRequest(); $request->service = "document_detection"; $serviceParameters = array("taskId" => "fi_f_O5z5iaIis*****NYj7qa-1x****"); $request->serviceParameters = json_encode($serviceParameters); $runtime = new RuntimeOptions(); $runtime->readTimeout = 6000; $runtime->connectTimeout = 3000; try { $response = $client->describeFileModerationResultWithOptions($request, $runtime); if (200 != $response->statusCode) { print_r("response not success. code:" . $response->statusCode); return; } $body = $response->body; print_r("requestId = " . $body->requestId . "\n"); print_r("code = " . $body->code . "\n"); print_r("message = " . $body->message . "\n"); if (280 == $body->code) { print_r("processing file moderation. code:" . $body->code); return; } if (200 != $body->code) { print_r("file moderation result not success. code:" . $body->code); return; } $data = $body->data; print_r("data = " . json_encode($data) . "\n"); print_r("pageResult = " . json_encode($data->pageResult) . "\n"); } catch (TeaUnableRetryError $e) { var_dump($e->getMessage()); var_dump($e->getErrorInfo()); var_dump($e->getLastException()); var_dump($e->getLastRequest()); }
Go SDK
執(zhí)行如下命令引入相關(guān)依賴。
go get github.com/alibabacloud-go/green-20220302
接入Go SDK。
提交文檔檢測任務(wù)代碼示例
package main import ( "encoding/json" "fmt" openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client" green20220302 "github.com/alibabacloud-go/green-20220302/v2/client" util "github.com/alibabacloud-go/tea-utils/v2/service" "github.com/alibabacloud-go/tea/tea" "net/http" ) func main() { // 工程代碼泄露可能會導(dǎo)致AccessKey泄露,并威脅賬號下所有資源的安全性。以下代碼示例僅供參考,建議使用更安全的STS方式。 config := &openapi.Config{ /** * 阿里云賬號AccessKey擁有所有API的訪問權(quán)限,建議您使用RAM用戶進(jìn)行API訪問或日常運(yùn)維。 * 強(qiáng)烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導(dǎo)致AccessKey泄露,威脅您賬號下所有資源的安全。 * 常見獲取環(huán)境變量方式: * 獲取RAM用戶AccessKey ID:os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID") * 獲取RAM用戶AccessKey Secret:os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET") */ AccessKeyId: tea.String("建議從環(huán)境變量中獲取RAM用戶AccessKey ID"), AccessKeySecret: tea.String("建議從環(huán)境變量中獲取RAM用戶AccessKey Secret"), RegionId: tea.String("cn-shanghai"), Endpoint: tea.String("green-cip.cn-shanghai.aliyuncs.com"), /** * 請?jiān)O(shè)置超時時間。服務(wù)端全鏈路處理超時時間為10秒,請做相應(yīng)設(shè)置。 * 如果您設(shè)置的ReadTimeout小于服務(wù)端處理的時間,程序中會獲得一個ReadTimeout異常。 */ ConnectTimeout: tea.Int(3000), ReadTimeout: tea.Int(6000), } client, _err := green20220302.NewClient(config) if _err != nil { panic(_err) } // 創(chuàng)建RuntimeObject實(shí)例并設(shè)置運(yùn)行參數(shù)。 runtime := &util.RuntimeOptions{} runtime.ReadTimeout = tea.Int(10000) runtime.ConnectTimeout = tea.Int(10000) serviceParameters, _ := json.Marshal( map[string]interface{}{ "url": "https://xxx.oss.aliyuncs.com/xxx.pdf", }, ) request := green20220302.FileModerationRequest{ Service: tea.String("document_detection"), ServiceParameters: tea.String(string(serviceParameters)), } result, _err := client.FileModerationWithOptions(&request, runtime) if _err != nil { panic(_err) } if *result.StatusCode != http.StatusOK { fmt.Printf("response not success. status:%d\n", *result.StatusCode) return } body := result.Body fmt.Printf("response success. requestId:%s, code:%d, msg:%s\n", *body.RequestId, *body.Code, *body.Message) if *body.Code != http.StatusOK { fmt.Printf("file moderation not success. code:%d\n", *body.Code) return } data := body.Data fmt.Printf("file moderation taskId:%s\n", *data.TaskId) }
獲取文檔檢測任務(wù)結(jié)果
package main import ( "encoding/json" "fmt" openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client" green20220302 "github.com/alibabacloud-go/green-20220302/v2/client" util "github.com/alibabacloud-go/tea-utils/v2/service" "github.com/alibabacloud-go/tea/tea" "net/http" ) func main() { // 工程代碼泄露可能會導(dǎo)致AccessKey泄露,并威脅賬號下所有資源的安全性。以下代碼示例僅供參考,建議使用更安全的STS方式。 config := &openapi.Config{ /** * 阿里云賬號AccessKey擁有所有API的訪問權(quán)限,建議您使用RAM用戶進(jìn)行API訪問或日常運(yùn)維。 * 強(qiáng)烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導(dǎo)致AccessKey泄露,威脅您賬號下所有資源的安全。 * 常見獲取環(huán)境變量方式: * 獲取RAM用戶AccessKey ID:os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID") * 獲取RAM用戶AccessKey Secret:os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET") */ AccessKeyId: tea.String("建議從環(huán)境變量中獲取RAM用戶AccessKey ID"), AccessKeySecret: tea.String("建議從環(huán)境變量中獲取RAM用戶AccessKey Secret"), RegionId: tea.String("cn-shanghai"), Endpoint: tea.String("green-cip.cn-shanghai.aliyuncs.com"), /** * 請?jiān)O(shè)置超時時間。服務(wù)端全鏈路處理超時時間為10秒,請做相應(yīng)設(shè)置。 * 如果您設(shè)置的ReadTimeout小于服務(wù)端處理的時間,程序中會獲得一個ReadTimeout異常。 */ ConnectTimeout: tea.Int(3000), ReadTimeout: tea.Int(6000), } client, _err := green20220302.NewClient(config) if _err != nil { panic(_err) } // 創(chuàng)建RuntimeObject實(shí)例并設(shè)置運(yùn)行參數(shù)。 runtime := &util.RuntimeOptions{} runtime.ReadTimeout = tea.Int(10000) runtime.ConnectTimeout = tea.Int(10000) serviceParameters, _ := json.Marshal( map[string]interface{}{ "taskId": "fi_f_O5z5iaIi******-1x****", }, ) request := green20220302.DescribeFileModerationResultRequest{ Service: tea.String("document_detection"), ServiceParameters: tea.String(string(serviceParameters)), } result, _err := client.DescribeFileModerationResultWithOptions(&request, runtime) if _err != nil { panic(_err) } if *result.StatusCode != http.StatusOK { fmt.Printf("response not success. status:%d\n", *result.StatusCode) return } body := result.Body fmt.Printf("response success. requestId:%s, code:%d, msg:%s\n", *body.RequestId, *body.Code, *body.Message) if *body.Code == 280 { fmt.Printf("processing file moderation. code:%d\n", *body.Code) return } if *body.Code != http.StatusOK { fmt.Printf("file moderation result not success. code:%d\n", *body.Code) return } data := body.Data fmt.Printf("file moderation result:%s\n", data) fmt.Printf("file moderation result pageResult:%s\n", data.PageResult) fmt.Printf("file moderation result dataId:%s\n", data.DataId) }