Online proctoring

更新时间:
复制 MD 格式

This topic provides code examples for the Online Proctoring service in common programming languages and for typical use cases.

Note
  • For real-time assistance, start an online consultation.

  • If you have questions about API access or usage for the Alibaba Cloud Vision AI Platform, join our DingTalk group (ID: 23109592) to contact us.

Introduction

For an introduction to the Online Proctoring service and its request parameters, see Online Proctoring.

SDK installation

For information about SDK dependencies for common programming languages, see SDK overview.

Configure environment variables

Configure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables.

Important
  • An Alibaba Cloud account has full access to all API operations. We recommend that you use a RAM user for API calls or routine O&M. For more information, see Create a RAM user.

  • Do not save your AccessKey ID or AccessKey Secret in project code. Otherwise, the AccessKey pair may be leaked and the security of all resources in your account may be compromised.

  • Configure environment variables on Linux and macOS

    1. Open a terminal in IntelliJ IDEA.

    2. Run the following commands to configure the environment variables.

      Replace <access_key_id> with the AccessKey ID of your RAM user and <access_key_secret> with the AccessKey Secret of your RAM user. If you need to configure more permissions, see Control access permissions using a RAM policy.

      export ALIBABA_CLOUD_ACCESS_KEY_ID=<access_key_id>
      export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<access_key_secret>
  • Configure environment variables on Windows

    Create a new environment variable file, add the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET, and set them to the AccessKey ID and AccessKey Secret that you have prepared. Then, restart the Windows operating system. The following example uses Windows 10.

    1. Open File Explorer, right-click This PC, and then select Properties.

    2. In the left-side navigation pane, click Advanced system settings.

    3. On the Advanced tab of the System Properties dialog box, click Environment Variables.

    4. In the Environment Variables dialog box, click New.

    5. In the New System Variable dialog box, add the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET, and set them to the AccessKey ID and AccessKey Secret that you have prepared.

    6. Restart the Windows operating system for the configurations to take effect.

Sample code

File from OSS (Shanghai)

// The minimum required SDK version is facebody20191230 v3.0.7.
// For the latest SDK version, see the repository: https://mvnrepository.com/artifact/com.aliyun/facebody20191230
// <dependency>
//       <groupId>com.aliyun</groupId>
//       <artifactId>facebody20191230</artifactId>
//       <version>${aliyun.facebody.version}</version>
// </dependency>

import com.aliyun.facebody20191230.models.MonitorExaminationResponse;
import com.aliyun.tea.TeaException;
import com.aliyun.tea.TeaModel;

public class MonitorExamination {

    public static com.aliyun.facebody20191230.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        /*
          Initialize the configuration object com.aliyun.teaopenapi.models.Config.
          The Config object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
         */
         com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setAccessKeyId(accessKeyId)
                .setAccessKeySecret(accessKeySecret);
        // The endpoint of the service.
        config.endpoint = "facebody.cn-shanghai.aliyuncs.com";
        return new com.aliyun.facebody20191230.Client(config);
    }

    public static void main(String[] args) throws Exception {
        // For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
        // If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
        // Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
        String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); 
        com.aliyun.facebody20191230.Client client = MonitorExamination.createClient(accessKeyId, accessKeySecret);
        com.aliyun.facebody20191230.models.MonitorExaminationRequest monitorExaminationRequest = new com.aliyun.facebody20191230.models.MonitorExaminationRequest()
                .setImageURL("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg")
                .setType(1L);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Print the API response.
            MonitorExaminationResponse response = client.monitorExaminationWithOptions(monitorExaminationRequest, runtime);
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(response)));
        } catch (TeaException error) {
            // Print the complete error message.
            System.out.println(com.aliyun.teautil.Common.toJSONString(error));
            // Print the error code.
            System.out.println(error.getCode());
        }
    }
}
# -*- coding: utf-8 -*-
# Import dependencies.
# The minimum required SDK version is facebody20191230 v4.0.8.
# For the latest SDK version, see the repository: https://pypi.org/project/alibabacloud-facebody20191230/
# pip install alibabacloud_facebody20191230

import os
from alibabacloud_facebody20191230.client import Client
from alibabacloud_facebody20191230.models import MonitorExaminationRequest
from alibabacloud_tea_openapi.models import Config
from alibabacloud_tea_util.models import RuntimeOptions

config = Config(
    # For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
    # If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
    # Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
    access_key_id=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID'),
    access_key_secret=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET'),
    # The endpoint of the service.
    endpoint='facebody.cn-shanghai.aliyuncs.com',
    # The region ID of the endpoint.
    region_id='cn-shanghai'
)
monitor_examination_request = MonitorExaminationRequest(
    image_url='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg',
    type=1
)
runtime = RuntimeOptions()
try:
  # Initialize the client.
  client = Client(config)
  response = client.monitor_examination_with_options(monitor_examination_request, runtime)
  # Print the complete response.
  print(response.body)
  # Tip: You can view attribute names by using response.body.__dict__.
except Exception as error:
  # Print the complete error message.
  print(error)
  # Print the error code.
  print(error.code)
<?php

// Install dependencies.
// The minimum required SDK version is facebody-20191230 v3.0.8.
// For the latest SDK version, see the repository: https://packagist.org/packages/alibabacloud/facebody-20191230    
// composer require alibabacloud/facebody-20191230

use AlibabaCloud\SDK\Facebody\V20191230\Facebody;
use AlibabaCloud\Tea\Utils\Utils;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Facebody\V20191230\Models\MonitorExaminationRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class MonitorExamination {

    /**
     * Initialize the client with an AccessKey pair.
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return Facebody Client
     */
    public static function createClient($accessKeyId, $accessKeySecret){
        // Initialize the configuration object Darabonba\OpenApi\Models\Config.
        // The Config object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
        $config = new Config([
            "accessKeyId" => $accessKeyId,
            "accessKeySecret" => $accessKeySecret
        ]);
        // The endpoint of the service.
        $config->endpoint = "facebody.cn-shanghai.aliyuncs.com";
        return new Facebody($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        // For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
        // If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
        // Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
        $accessKeyId = getenv('ALIBABA_CLOUD_ACCESS_KEY_ID');      
        $accessKeySecret = getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
        $client = self::createClient($accessKeyId, $accessKeySecret);
        $monitorExaminationRequest = new MonitorExaminationRequest([
            "type" => 1,
            "imageURL" => "http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg"
        ]);
        $runtime = new RuntimeOptions([]);
        try {
            $resp = $client->monitorExaminationWithOptions($monitorExaminationRequest, $runtime);
            echo Utils::toJSONString($resp->body);
        } catch (Exception $exception) {
            # Print the complete error message.
            echo Utils::toJSONString($exception);
            # Print the error code.
            echo $exception->getCode();
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
// The `$argv` array is reserved for input parameters and does not need to be modified.
MonitorExamination::main(array_slice($argv, 1));
// Install dependencies.
// npm install @alicloud/facebody20191230
// The minimum required SDK version is facebody20191230 v4.0.7.
// For the latest SDK version, see the repository: https://npmjs.com/package/@alicloud/facebody20191230
const FacebodyClient = require('@alicloud/facebody20191230');
const OpenapiClient = require('@alicloud/openapi-client');
const TeaUtil = require('@alicloud/tea-util');

let config = new OpenapiClient.Config({
    // For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
    // If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
    // Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
    accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,   
    accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET
});
// The endpoint of the service.
config.endpoint = `facebody.cn-shanghai.aliyuncs.com`;
const client = new FacebodyClient.default(config);
let monitorExaminationRequest = new FacebodyClient.MonitorExaminationRequest({
  type: 1,
  imageURL: "http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg",
});
let runtime = new TeaUtil.RuntimeOptions({});
client.monitorExaminationWithOptions(monitorExaminationRequest, runtime)
  .then(function (monitorExaminationResponse) {
    // Print the complete response.
    console.log(monitorExaminationResponse);
    // Print a single field from the response.
    console.log(monitorExaminationResponse.body.data);
  }, function (error) {
    // Print the complete error message.
    console.log(error);
    // Print the error code.
    console.log(error.data.Code);
  })
// Import dependencies.
// The minimum required SDK version is facebody20191230 v4.0.7.
// For the latest SDK version, see the repository: github.com/alibabacloud-go/facebody-20191230/v4
// go get github.com/alibabacloud-go/facebody-20191230/v4

package main

import (
	"fmt"
	openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
	facebody20191230 "github.com/alibabacloud-go/facebody-20191230/v4/client"
	util "github.com/alibabacloud-go/tea-utils/v2/service"
	"github.com/alibabacloud-go/tea/tea"
)

func main() {
	// For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
	// If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
	// Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
	accessKeyId := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")  
	accessKeySecret := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
	// Initialize the configuration object &openapi.Config. The Config object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
	config := &openapi.Config{
          AccessKeyId: tea.String(accessKeyId),
          AccessKeySecret: tea.String(accessKeySecret)
	}
	// The endpoint of the service.
	config.Endpoint = tea.String("facebody.cn-shanghai.aliyuncs.com")
	client, err := facebody20191230.NewClient(config)
	if err != nil {
		fmt.Println(err.Error())
	}

	monitorExaminationRequest := &facebody20191230.MonitorExaminationRequest{
		ImageURL: tea.String("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg"),
		Type: tea.Int64(1),
	}
	runtime := &util.RuntimeOptions{}
	monitorExaminationResponse, _err := client.MonitorExaminationWithOptions(monitorExaminationRequest, runtime)
	if _err != nil {
		fmt.Println(_err.Error())
	} else {
		// Print the complete response.
		fmt.Println(monitorExaminationResponse)
		// Print a single field from the response.
		fmt.Println(monitorExaminationResponse.Body.Data)
	}
}
// Install dependencies.
// dotnet add package AlibabaCloud.SDK.Facebody20191230
// The minimum required SDK version is facebody20191230 v3.0.7.
// For the latest SDK version, see the repository: https://nuget.org/packages/AlibabaCloud.SDK.Facebody20191230
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using AlibabaCloud.SDK.Facebody20191230.Models;
using Tea;
using Tea.Utils;

namespace AlibabaCloud.SDK.Sample
{
    public class Sample
    {
        /**
            * Initialize the client with an AccessKey pair.
            * @param accessKeyId
            * @param accessKeySecret
            * @return Client
            * @throws Exception
        */
        public static AlibabaCloud.SDK.Facebody20191230.Client CreateClient(string accessKeyId, string accessKeySecret)
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                AccessKeyId = accessKeyId,
                AccessKeySecret = accessKeySecret,
            };
            // The endpoint of the service.
            config.Endpoint = "facebody.cn-shanghai.aliyuncs.com";
            return new AlibabaCloud.SDK.Facebody20191230.Client(config);
        }
        public static void Main(string[] args)
        {
            // For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
            // If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
            // Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
            AlibabaCloud.SDK.Facebody20191230.Client client = CreateClient(System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
            AlibabaCloud.SDK.Facebody20191230.Models.MonitorExaminationRequest monitorExaminationRequest = new AlibabaCloud.SDK.Facebody20191230.Models.MonitorExaminationRequest
            {
                Type = 1,
                ImageURL = "http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg",
            };
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            try
            {
                AlibabaCloud.SDK.Facebody20191230.Models.MonitorExaminationResponse monitorExaminationResponse = client.MonitorExaminationWithOptions(monitorExaminationRequest, runtime);
                // Print the complete response body.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(monitorExaminationResponse.Body));
                // Print a single field from the response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(monitorExaminationResponse.Body.Data));
            }
            catch (TeaException error)
            {
                // Print the error message.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // Print the error message.
                Console.WriteLine(error.Message);
            }
        }
    }
}

Local file or URL

// The minimum required SDK version is facebody20191230 v3.0.7.
// For the latest SDK version, see the repository: https://mvnrepository.com/artifact/com.aliyun/facebody20191230
// <dependency>
//       <groupId>com.aliyun</groupId>
//       <artifactId>facebody20191230</artifactId>
//       <version>${aliyun.facebody.version}</version>
// </dependency>

import com.aliyun.facebody20191230.models.MonitorExaminationResponse;
import com.aliyun.tea.TeaException;
import com.aliyun.tea.TeaModel;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;

public class MonitorExamination {

    public static com.aliyun.facebody20191230.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        /*
          Initialize the configuration object com.aliyun.teaopenapi.models.Config.
          The Config object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
         */
         com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setAccessKeyId(accessKeyId)
                .setAccessKeySecret(accessKeySecret);
        // The endpoint of the service.
        config.endpoint = "facebody.cn-shanghai.aliyuncs.com";
        return new com.aliyun.facebody20191230.Client(config);
    }

    public static void main(String[] args) throws Exception {
        // For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
        // If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
        // Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
        String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); 
        com.aliyun.facebody20191230.Client client = MonitorExamination.createClient(accessKeyId, accessKeySecret);
        // Scenario 1: Use a local file.
//         InputStream inputStream = new FileInputStream(new File("/tmp/MonitorExamination1.jpg"));
        // Scenario 2: Use a publicly accessible URL.
        URL url = new URL("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg");
        InputStream inputStream = url.openConnection().getInputStream();
        com.aliyun.facebody20191230.models.MonitorExaminationAdvanceRequest monitorExaminationAdvanceRequest = new com.aliyun.facebody20191230.models.MonitorExaminationAdvanceRequest()
                .setImageURLObject(inputStream)
                .setType(1L);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Print the API response.
            MonitorExaminationResponse response = client.monitorExaminationAdvance(monitorExaminationAdvanceRequest, runtime);
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(response)));
        } catch (TeaException error) {
            // Print the complete error message.
            System.out.println(com.aliyun.teautil.Common.toJSONString(error));
            // Print the error code.
            System.out.println(error.getCode());
        }
    }
}
# -*- coding: utf-8 -*-
# Import dependencies.
# The minimum required SDK version is facebody20191230 v4.0.8.
# For the latest SDK version, see the repository: https://pypi.org/project/alibabacloud-facebody20191230/
# pip install alibabacloud_facebody20191230

import os
import io
from urllib.request import urlopen
from alibabacloud_facebody20191230.client import Client
from alibabacloud_facebody20191230.models import MonitorExaminationAdvanceRequest
from alibabacloud_tea_openapi.models import Config
from alibabacloud_tea_util.models import RuntimeOptions

config = Config(
    # For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
    # If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
    # Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
    access_key_id=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID'),
    access_key_secret=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET'),
    # The endpoint of the service.
    endpoint='facebody.cn-shanghai.aliyuncs.com',
    # The region ID of the endpoint.
    region_id='cn-shanghai'
)
# Scenario 1: Use a local file.
#img = open(r'/tmp/1MonitorExamination1.jpg', 'rb')
# Scenario 2: Use a publicly accessible URL.
url = 'http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg'
img = io.BytesIO(urlopen(url).read())
monitor_examination_request = MonitorExaminationAdvanceRequest()
monitor_examination_request.image_urlobject = img
monitor_examination_request.type = 1
runtime = RuntimeOptions()
try:
  # Initialize the client.
  client = Client(config)
  response = client.monitor_examination_advance(monitor_examination_request, runtime)
  # Print the complete response.
  print(response.body)
  # Tip: You can view attribute names by using response.body.__dict__.
except Exception as error:
  # Print the complete error message.
  print(error)
  # Print the error code.
  print(error.code)
<?php

// Install dependencies.
// The minimum required SDK version is facebody-20191230 v3.0.8.
// For the latest SDK version, see the repository: https://packagist.org/packages/alibabacloud/facebody-20191230    
// composer require alibabacloud/facebody-20191230

use AlibabaCloud\SDK\Facebody\V20191230\Facebody;
use AlibabaCloud\Tea\Utils\Utils;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Facebody\V20191230\Models\MonitorExaminationAdvanceRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use GuzzleHttp\Psr7\Stream;

class MonitorExaminationAdvance {

    /**
     * Initialize the client with an AccessKey pair.
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return Facebody Client
     */
    public static function createClient($accessKeyId, $accessKeySecret){
        // Initialize the configuration object Darabonba\OpenApi\Models\Config.
        // The Config object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
        $config = new Config([
            "accessKeyId" => $accessKeyId,
            "accessKeySecret" => $accessKeySecret
        ]);
        // The endpoint of the service.
        $config->endpoint = "facebody.cn-shanghai.aliyuncs.com";
        return new Facebody($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        // For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
        // If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
        // Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
        $accessKeyId = getenv('ALIBABA_CLOUD_ACCESS_KEY_ID');      
        $accessKeySecret = getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
        $client = self::createClient($accessKeyId, $accessKeySecret);
        // Scenario 1: Use a local file.
        //$file = fopen('/tmp/1MonitorExamination1.jpg', 'rb');
        //$stream = new Stream($file);
        // Scenario 2: Use a publicly accessible URL.
        $file = fopen('http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg', 'rb');
        $stream = new Stream($file);
        $monitorExaminationAdvanceRequest = new MonitorExaminationAdvanceRequest([
            "type" => 1,
            "imageURLObject" => $stream
        ]);
        $runtime = new RuntimeOptions([]);
        try {
            $resp = $client->monitorExaminationAdvance($monitorExaminationAdvanceRequest, $runtime);
            echo Utils::toJSONString($resp->body);
        } catch (Exception $exception) {
            # Print the complete error message.
            echo Utils::toJSONString($exception);
            # Print the error code.
            echo $exception->getCode();
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
// The `$argv` array is reserved for input parameters and does not need to be modified.
MonitorExaminationAdvance::main(array_slice($argv, 1));
// Install dependencies.
// npm install @alicloud/facebody20191230
// The minimum required SDK version is facebody20191230 v4.0.7.
// For the latest SDK version, see the repository: https://npmjs.com/package/@alicloud/facebody20191230
const FacebodyClient = require('@alicloud/facebody20191230');
const OpenapiClient = require('@alicloud/openapi-client');
const TeaUtil = require('@alicloud/tea-util');
const fs = require('fs');
const http = require('http');
const https = require('https');

let config = new OpenapiClient.Config({
    // For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
    // If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
    // Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
    accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,   
    accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET
});
// The endpoint of the service.
config.endpoint = `facebody.cn-shanghai.aliyuncs.com`;
const client = new FacebodyClient.default(config);
const getResponse = function (httpClient, url) {
  return new Promise((resolve, reject) => {
    httpClient.get(url, function (response) {
      resolve(response);
    })
  })
}
const request = async function () {
  try {
    const client = new FacebodyClient.default(config);
    let monitorExaminationAdvanceRequest = new FacebodyClient.MonitorExaminationAdvanceRequest();
    // Scenario 1: Use a local file.
    // const fileStream = fs.createReadStream('/tmp/1MonitorExamination1.jpg');
    // monitorExaminationAdvanceRequest.imageURLObject = fileStream;
    // monitorExaminationAdvanceRequest.type = 1;
    // Scenario 2: Use a publicly accessible URL.
    const url = new URL("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg");
    const httpClient = (url.protocol == "https:") ? https : http;
    monitorExaminationAdvanceRequest.imageURLObject = await getResponse(httpClient, url);
    monitorExaminationAdvanceRequest.type = 1;
    let runtime = new TeaUtil.RuntimeOptions({ });
    client.monitorExaminationAdvance(monitorExaminationAdvanceRequest, runtime)
      .then(function(monitorExaminationResponse) {
        // Print the complete response.
        console.log(monitorExaminationResponse);
        // Print a single field from the response.
        console.log(monitorExaminationResponse.body.data);
      }, function(error) {
        // Print the complete error message.
        console.log(error);
        // Print the error code.
        console.log(error.data.Code);
      })
  } catch (error) {
    console.log(error);
  }
}();
// Import dependencies.
// The minimum required SDK version is facebody20191230 v4.0.7.
// For the latest SDK version, see the repository: github.com/alibabacloud-go/facebody-20191230/v4
// go get github.com/alibabacloud-go/facebody-20191230/v4

package main

import (
	"fmt"
	openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
	facebody20191230 "github.com/alibabacloud-go/facebody-20191230/v4/client"
	util "github.com/alibabacloud-go/tea-utils/v2/service"
	"github.com/alibabacloud-go/tea/tea"
	"net/http"
)

func main() {
	// For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
	// If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
	// Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
	accessKeyId := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")  
	accessKeySecret := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
	// Initialize the configuration object &openapi.Config. The Config object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
	config := &openapi.Config{
          AccessKeyId: tea.String(accessKeyId),
          AccessKeySecret: tea.String(accessKeySecret)
	}
	// The endpoint of the service.
	config.Endpoint = tea.String("facebody.cn-shanghai.aliyuncs.com")
	client, err := facebody20191230.NewClient(config)
	if err != nil {
		fmt.Println(err.Error())
	}

	// Scenario 1: Use a local file.
	//file, err := os.Open("/tmp/MonitorExamination1.mp4")
	//if err != nil {
	//	fmt.Println("can not open file", err)
	//}
	//monitorExaminationAdvanceRequest := &facebody20191230.MonitorExaminationAdvanceRequest{
	//	ImageURLObject: file,
	//	Type: tea.Int64(1),
	//}
	// Scenario 2: Use a publicly accessible URL.
	httpClient := http.Client{}
	file1, _ := httpClient.Get("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg")
	monitorExaminationAdvanceRequest := &facebody20191230.MonitorExaminationAdvanceRequest{
		ImageURLObject: file1.Body,
		Type: tea.Int64(1),
	}
	runtime := &util.RuntimeOptions{}
	monitorExaminationResponse, _err := client.MonitorExaminationAdvance(monitorExaminationAdvanceRequest, runtime)
	if _err != nil {
		fmt.Println(_err.Error())
	} else {
		// Print the complete response.
		fmt.Println(monitorExaminationResponse)
		// Print a single field from the response.
		fmt.Println(monitorExaminationResponse.Body.Data)
	}
}
// Install dependencies.
// dotnet add package AlibabaCloud.SDK.Facebody20191230
// The minimum required SDK version is facebody20191230 v3.0.7.
// For the latest SDK version, see the repository: https://nuget.org/packages/AlibabaCloud.SDK.Facebody20191230
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using AlibabaCloud.SDK.Facebody20191230.Models;
using Tea;
using Tea.Utils;

namespace AlibabaCloud.SDK.Sample
{
    public class Sample
    {
        /**
            * Initialize the client with an AccessKey pair.
            * @param accessKeyId
            * @param accessKeySecret
            * @return Client
            * @throws Exception
        */
        public static AlibabaCloud.SDK.Facebody20191230.Client CreateClient(string accessKeyId, string accessKeySecret)
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                AccessKeyId = accessKeyId,
                AccessKeySecret = accessKeySecret,
            };
            // The endpoint of the service.
            config.Endpoint = "facebody.cn-shanghai.aliyuncs.com";
            return new AlibabaCloud.SDK.Facebody20191230.Client(config);
        }
        public static void Main(string[] args)
        {
            // For information about how to create an AccessKey, see https://help.aliyun.com/document_detail/175144.html.
            // If you use a RAM user's AccessKey, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
            // Obtain the AccessKey ID and AccessKey Secret from environment variables. Before you run the sample code, make sure that you have configured the environment variables.
            AlibabaCloud.SDK.Facebody20191230.Client client = CreateClient(System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
            AlibabaCloud.SDK.Facebody20191230.Models.MonitorExaminationAdvanceRequest monitorExaminationAdvanceRequest = new AlibabaCloud.SDK.Facebody20191230.Models.MonitorExaminationAdvanceRequest
            ();
            // Scenario 1: Use a local file.
            //System.IO.StreamReader file = new System.IO.StreamReader(@"/tmp/1MonitorExamination1.jpg");
            //monitorExaminationAdvanceRequest.ImageURLObject = file.BaseStream;
            //monitorExaminationAdvanceRequest.Type = 1;

            // Scenario 2: Use a publicly accessible URL.
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg");
            WebResponse response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            monitorExaminationAdvanceRequest.ImageURLObject = stream;
            monitorExaminationAdvanceRequest.Type = 1;

            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            try
            {
                AlibabaCloud.SDK.Facebody20191230.Models.MonitorExaminationResponse monitorExaminationResponse = client.MonitorExaminationAdvance(monitorExaminationAdvanceRequest, runtime);
                // Print the complete response body.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(monitorExaminationResponse.Body));
                // Print a single field from the response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(monitorExaminationResponse.Body.Data));
            }
            catch (TeaException error)
            {
                // Print the error message.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // Print the error message.
                Console.WriteLine(error.Message);
            }
        }
    }
}