昨天开始突然不管输入政治人物还是相关违禁词,都是返回通过,检查了编码都没有问题,不管输入什么都是返回100
【微信接口返回的原始响应】
{"errcode":0,"errmsg":"ok","detail":[{"strategy":"content_model","errcode":0,"suggest":"pass","label":100,"prob":90},{"strategy":"keyword","errcode":0}],"trace_id":"67d1084d-0101baff-347b8a13","result":{"suggest":"pass","label":100}}
// 调用 msgSecCheck 函数
msgSecCheck($content, $version, $scene, $openid, $jsonData);
function msgSecCheck($content, $version, $scene, $openid, $postData, $title = '', $nickname = '', $signature = '') {
// 从文件中读取 access_token
$accessToken = file_exists("access_token.txt") ? trim(file_get_contents("access_token.txt")) : "your_hardcoded_access_token";
$url = "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" . $accessToken;
// 直接使用原始 $content(确保是 UTF-8 编码)
$data = array(
'openid' => $openid,
'scene' => $scene,
'version' => $version,
'content' => $content,
'title' => $title,
'nickname' => $nickname,
'signature' => $signature,
);
// 合并额外的数据(如果有的话)
if ($postData && is_array($postData)) {
$data = array_merge($data, $postData);
}
// 调试:打印将要发送给微信接口的数据
echo "<pre>【发送给微信接口的数据】\n" . htmlspecialchars(json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), ENT_QUOTES, 'UTF-8') . "\n</pre>";
$options = array(
'http' => array(
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
),
);
$context = stream_context_create($options);
// 发起 HTTPS POST 请求到微信接口
$apiResult = file_get_contents($url, false, $context);
$response = json_decode($apiResult, true);
// 调试:打印微信接口返回的原始响应
echo "<pre>【微信接口返回的原始响应】\n" . htmlspecialchars($apiResult, ENT_QUOTES, 'UTF-8') . "\n</pre>";
// 处理响应
if (isset($response['errcode']) && $response['errcode'] === 0 && isset($response['result']['suggest'])) {
$suggest = $response['result']['suggest'];
$label = isset($response['result']['label']) ? $response['result']['label'] : null;
$resultData = array(
'status' => 'success',
'message' => '',
'label' => $label,
'suggest' => $suggest
);
if ($label === 100) {
$resultData['message'] = "内容是干净的!";
} else {
$resultData['message'] = "内容存在风险,需要进一步处理!";
}
echo json_encode($resultData, JSON_UNESCAPED_UNICODE);
} else {
$errorData = array(
'status' => 'error',
'message' => "API 调用失败或返回无效的结果。",
'response' => $response,
);
echo json_encode($errorData, JSON_UNESCAPED_UNICODE);
}
}
你好,已处理,请重试看看。
好像还是一样
在外面忙晚上才有电脑 小程序里测试还是老样子
怎么调用的,发出来看下
还请管理帮忙看看呀,是不是接口失效了
没有官方回复下吗 实在找不出问题啊