文本内容安全识别不出敏感词呢?我写的哪里有问题呀,急急
部分代码如下:
$access_token = json_decode($this->access_token())->access_token;
$endpoint = "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=".$access_token;
Log::info('微信检测敏感词url',[$endpoint]);
$params = [
'openid' => $open_id['openid'],
'scene' => 4,
'version' => 2,
'content' => "测试数据:反动分子大麻海洛因台独一个台湾测试数据",
];
Log::info('微信检测敏感词params',[$params]);
$result = $this->postsCurl($params,$endpoint);
return [true,$result];
}
public function postsCurl(array $data,$endpoint)
{
// 构造请求头
$headers = array(
'Content-Type: application/json'
);
// 定义变量
$url = $endpoint;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
Log::info('微信检测敏感词检测结果',[$response]);
return json_decode($response, true);
}
Log打印结果: [2024-07-24 14:23:30] local.INFO: 微信检测敏感词params [{"openid":"oo5Kt5GkFBZMSfVuspTWWU","scene":4,"version":2,"content":"测试数据:反动分子大麻海洛因台独一个台湾测试数据"}] [2024-07-24 14:23:30] local.INFO: 微信检测敏感词url ["https://api.weixin.qq.com/wxa/msg_sec_check?access_token=82_uKM2Ag80M7rrrwcZ5FnLxpjZkRyjPkagvd_-3FAOREVUNFEYzhltzKEiF0_fX2C6BxzkdSr_jJslZwySgCYghObBGGCEXOicCpc2q2VxgLrqzDE7aw_EACALLM"] 微信检测敏感词检测结果:{ "errcode": 0, "errmsg": "ok", "detail": [ { "strategy": "keyword", "errcode": 0 }, { "strategy": "content_model", "errcode": 0, "suggest": "pass", "label": 100, "prob": 90 } ], "trace_id": "66a09de2-154c2720-2cb5f", "result": { "suggest": "pass", "label": 100 } }