Creating a Video Moderation Job
- This section describes how to create a video moderation job using the video moderation SDK and AK/SK.
In the sample code, you can use withUrls of the RunCreateVideoModerationJobRequest class to configure the URL of the video to be reviewed (only the URL mode is supported). After the configuration is complete, run the code.
For details about how to obtain the project ID, see Obtaining a Project ID.
<?php namespace HuaweiCloud\SDK\Moderation\V3\Model; require_once "vendor/autoload.php"; use HuaweiCloud\SDK\Core\Auth\BasicCredentials; use HuaweiCloud\SDK\Core\Http\HttpConfig; use HuaweiCloud\SDK\Core\Exceptions\ConnectionException; use HuaweiCloud\SDK\Core\Exceptions\RequestTimeoutException; use HuaweiCloud\SDK\Core\Exceptions\ServiceResponseException; use HuaweiCloud\SDK\Moderation\V3\ModerationClient; // Hard-coded or plaintext AK and SK are risky. For security purposes, encrypt your AK and SK and store them in the configuration file or environment variables. // In this example, the AK and SK are stored in environment variables for identity authentication. Before running this example, configure environment variables HUAWEICLOUD_SDK_AK, HUAWEICLOUD_SDK_SK, and HUAWEICLOUD_SDK_PROJECT_ID. $ak = getenv('HUAWEICLOUD_SDK_AK'); $sk = getenv('HUAWEICLOUD_SDK_SK'); $projectId = getenv('HUAWEICLOUD_SDK_PROJECT_ID'); $endpoint = "https://moderation.ap-southeast-3.myhuaweicloud.com";//Replace ap-southeast-3 with the region where the service is located. $credentials = new BasicCredentials($ak,$sk,$projectId); $config = HttpConfig::getDefaultConfig(); $config->setIgnoreSslVerification(true); $client = ModerationClient::newBuilder(new ModerationClient) ->withHttpConfig($config) ->withEndpoint($endpoint) ->withCredentials($credentials) ->build(); $request = new RunCreateVideoModerationJobRequest(); $body = new VideoCreateRequest(); $listbodyAudioCategories = array(); array_push($listbodyAudioCategories,"porn"); $listbodyImageCategories = array(); array_push($listbodyImageCategories,"porn"); $databody = new VideoCreateRequestData(); $databody->setUrl("http://xxx.xx.xxxx") ->setFrameInterval(5); $body->setAudioCategories($listbodyAudioCategories); $body->setImageCategories($listbodyImageCategories); $body->setEventType("default"); $body->setData($databody); $request->setBody($body); try { $response = $client->RunCreateVideoModerationJob($request); echo "\n"; echo $response; } catch (ConnectionException $e) { $msg = $e->getMessage(); echo "\n". $msg ."\n"; } catch (RequestTimeoutException $e) { $msg = $e->getMessage(); echo "\n". $msg ."\n"; } catch (ServiceResponseException $e) { echo "\n"; echo $e->getHttpStatusCode(). "\n"; echo $e->getErrorCode() . "\n"; echo $e->getErrorMsg() . "\n"; }
- The console returns the submission result of the creation request and the video moderation job creation result.
{"request_id": "dbbcb75d1a174bfa899a38be38fdd107", "job_id": "xxx"}
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot