With the rapid development of the internet, an increasing amount of video content is being uploaded to various platforms. However, some videos may contain harmful, illegal, or inappropriate information. To protect users' rights, platforms need efficient video content review tools. Baidu provides a powerful video content review API, and in this article, we will guide you step-by-step on how to integrate it with PHP.
<?php // Replace with your own API Key and Secret Key define('API_KEY', 'your_api_key'); define('SECRET_KEY', 'your_secret_key');
Now, we can begin using the Baidu Video Content Review API to review videos.
<?php require_once 'path_to_sdk/AipContentCensor/AipContentCensor.php'; require_once 'config.php'; // Create SDK object $client = new AipContentCensor(API_KEY, SECRET_KEY); // Perform video review $response = $client->videoCensorUserDefined('path_to_video_file'); // Output review result var_dump($response);
In the code above, we use the videoCensorUserDefined method to review the video. Be sure to replace "path_to_sdk" with the actual path of your SDK, and "path_to_video_file" with the path of the video file you want to review.
Once the PHP file is executed, you will receive a JSON string containing the review result. You can analyze the fields to determine whether the video is compliant. Below is an example of a response:
Array ( [conclusion] => Not Compliant [log_id] => 2021081800000001 [data] => Array ( [0] => Array ( [subType] => ocr Sampling Check [conclusion] => Not Compliant [msg] => 【Sampling Check】Textual Pornographic Content ) [1] => Array ( [subType] => porn Pornographic [conclusion] => Not Compliant [msg] => 【Porn】【Pornographic】 ) ) )
In this example, the "conclusion" field indicates the review result of the video. If it says "Not Compliant," the video may contain issues. The "log_id" is a unique ID for this review, useful for tracking the audit records.
By following the steps above, we successfully integrated Baidu's Video Content Review API with PHP and implemented video content review functionality. With Baidu's powerful content review technology, we can more efficiently filter out inappropriate content and ensure that the platform’s content complies with relevant regulations. We hope this article helps you in the video review process, making it easier to manage content on your platform.