With the widespread use of social media and content sharing platforms, user-uploaded text and images may contain inappropriate or violating content. To ensure a better user experience on the platform, we need to review this content. This article will introduce how to implement text and image review functionalities using PHP and Baidu AI.
The purpose of text review is to identify and filter out inappropriate text content, such as sensitive words, pornography, violence, and politically sensitive content.
Before we begin, you need to register on Baidu AI platform and create a text review application. Then, you need to include Baidu AI SDK in your PHP code:
After instantiating the client, you can use Baidu AI's API to initiate a text review request. Below is a simple example:
In this example, we use the textCensorUserDefined API to review a text containing sensitive words. The API will return a result where the conclusionType field indicates the review result, with 1 meaning passed and 2 meaning failed.
The purpose of image review is to identify and filter out inappropriate images, such as pornography, blood, violence, and politically sensitive content.
Similarly, before starting, you need to register on Baidu AI platform and create an image review application. Then, you need to instantiate a Baidu AI Client using the SDK:
After instantiating the client, you can use Baidu AI's API to initiate an image review request. Below is a simple example:
In this example, we use the imageCensorUserDefined API to review an image. The API will return a result where the conclusionType field indicates the review result, with 1 meaning passed and 2 meaning failed.
By using PHP and Baidu AI, we can easily implement text and image review functionalities. This feature is essential for protecting user privacy and improving platform content quality. We hope this article has been helpful to you. Thank you for reading!