Home > Article > Backend Development > Teach you step by step how to use PHP to connect to Baidu video content review interface
Teach you step by step how to use PHP to interface with Baidu video content review interface
Introduction:
With the development of the Internet, a large amount of video content has been uploaded to major platforms superior. However, there are many videos with illegal information, vulgar violence and other bad information. In order to protect the legitimate rights and interests of users, major platforms are strengthening the review of video content. Baidu provides a powerful video content review interface that can effectively help us review video content. This article will take you step by step to use PHP language to connect to Baidu video content review interface.
Step 1: Apply for Baidu Video Content Review Interface
Step 2: Install PHP SDK
<?php // 替换为自己的API Key和Secret Key define('API_KEY', 'your_api_key'); define('SECRET_KEY', 'your_secret_key');
<?php require_once 'AipContentCensor/AipContentCensor.php'; require_once 'config.php'; // 创建SDK对象 $client = new AipContentCensor(API_KEY, SECRET_KEY);
Step 3: Call the video review interface
Now, we can start using the Baidu video content review interface for video review.
<?php require_once 'path_to_sdk/AipContentCensor/AipContentCensor.php'; require_once 'config.php'; // 创建SDK对象 $client = new AipContentCensor(API_KEY, SECRET_KEY); // 视频审核 $response = $client->videoCensorUserDefined('path_to_video_file'); // 输出审核结果 var_dump($response);
In the code, we use The videoCensorUserDefined
method reviews the video. You need to replace path_to_sdk
with your SDK path and path_to_video_file
with the video file path that needs to be reviewed.
Code example:
Array ( [conclusion] => 不合规 [log_id] => 2021081800000001 [data] => Array ( [0] => Array ( [subType] => ocr 抽样检查 [conclusion] => 不合规 [msg] => 【抽样检查】文字色情信息 ) [1] => Array ( [subType] => porn 色情 [conclusion] => 不合规 [msg] => 【Porn】【色情】 ) ) )
In the above example, the conclusion
field represents the review result of the video. The log_id
field is the log ID of this audit. The array in the data
field represents the non-compliance type, audit conclusion and audit information.
Summary:
Through the above steps, we successfully used PHP to connect to the Baidu video content review interface and implemented the function of reviewing videos. I hope this article can help you strengthen the review of video content and protect the legitimate rights and interests of users.
The above is the detailed content of Teach you step by step how to use PHP to connect to Baidu video content review interface. For more information, please follow other related articles on the PHP Chinese website!