Detecting Audio, Video, and Image Content Risks in WeChat Mini Programs
This article walks through using the WeChat Mini Program media‑check API to identify risky audio, video, and image content, outlines three typical scenarios, explains platform rate limits, and provides a complete Java example with step‑by‑step code analysis.
Background
WeChat Mini Programs provide an asynchronous media‑content security detection API that can scan audio, video, and images for prohibited or illegal material.
Documentation Reference
The official API reference is shown in the image below.
Typical Application Scenarios
Voice risk detection – scanning user‑submitted audio.
Intelligent image porn detection – analyzing photos taken or uploaded by users.
Sensitive face recognition – checking avatars, article images, and other user‑uploaded pictures.
Usage Limits
Each appid: up to 2 000 calls per minute and 200 000 calls per day.
Each uploaded file must not exceed 10 MB.
Java Implementation
The following method demonstrates how to call the asynchronous media‑check endpoint. The request body follows the format defined in the Mini Program documentation.
public static void mediaCheckAsync(String access_token, String openid) {
System.out.println(access_token);
String params = "{\"openid\": \"OPENID\",
" +
"\"scene\": 1,
" +
"\"version\":2, \"media_url\":\"https://developers.weixin.qq.com/miniprogram/assets/images/[email protected]\",\"media_type\":2
" +
"}";
String s = params.replaceAll("OPENID", openid);
String msg_sec_check = MEDIA_CHECK_ASYNC.replaceAll("ACCESS_TOKEN", access_token);
String s1 = HttpUtils.httpsRequest(msg_sec_check, "POST", s);
// JSONObject jsonObject = JSONObject.parseObject(s1);
// JSONObject result = (JSONObject)jsonObject.get("result");
// String suggest = (String)result.get("suggest");
System.out.println(s1);
}Step‑by‑Step Explanation
Assemble the JSON payload; replace the placeholder OPENID with the actual user identifier. The media_url can be changed to point to any audio, video, or image file that complies with the size limit.
Insert the access_token into the request URL (the constant MEDIA_CHECK_ASYNC contains the endpoint template).
Send a POST request to the WeChat server. WeChat processes the media asynchronously and pushes the detection result to the developer‑configured callback URL within 30 minutes.
Print the raw response; in production code the response should be parsed into a JSON object to read fields such as suggest that indicate the detection outcome.
Callback Requirement
The developer must configure a message‑push server address; WeChat will invoke this endpoint to deliver the asynchronous result.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Coder Trainee
Experienced in Java and Python, we share and learn together. For submissions or collaborations, DM us.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
