微信小程序内容安全(已测试)
https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.msgSecCheck.html
public function index()
{
$content = '特3456书yuuo莞6543李zxcz蒜7782法fgnv级完2347全dfji试3726测asad感3847知qwez到';
$result = $this->curlText($content);
print_r($result);
}
//检测文本是否含有违禁内容(频率限制:单个 appId 调用上限为 1000 次/分钟,100,000 次/天)
private function curlText($content){
$ACCESS_TOKEN='nJad3gecta33X2MhKjuEfvsWL3kdA2Bjh8hKgAQkziArbbL82WGXfAFALPG';
//自己获取access_token
$url = "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=".$ACCESS_TOKEN;
$file_data = '{ "content":"'.$content.'" }';//$content(需要检测的文本内容,最大520KB)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch , CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch , CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $file_data);
$output = curl_exec($ch);//发送请求获取结果
$output=json_decode($output,false);
curl_close($ch);//关闭会话
return $output;//返回结果
}
stdClass Object
(
[errcode] => 87014
[errmsg] => risky content hint: [1nIRKA08811543]
)
stdClass Object
(
[errcode] => 0
[errmsg] => ok
)