/**
* 文本内容安全校验
* @param $params
* @return array
*/
public static function msgSecCheck($params){
// 获取 access_token
$result = WechatToken::getAppletAccessToken();
if ($result['code']) {
$access_token = $result['data'];
} else {
return ['code' => 0, 'msg' => $result['msg']];
}
$url = 'https://api.weixin.qq.com/wxa/msg_sec_check?access_token=' . $access_token;
$data = [
'content' => $params['content'],
];
$data = json_encode($data,JSON_UNESCAPED_UNICODE);
$res = self::https_request($url, $data);
$result = json_decode($res, true); // 格式化为数组
if($result['errcode'] == 0){
return ['code' => 1, 'msg' => 'Ok'];
} else {
return ['code' => 0, 'msg' => '内容不正常'];
}
}
参数示例
$params = [
'content' => '检验的文字的内容',
];
标签:code,检测,程序,access,params,result,msg,文本,data
From: https://www.cnblogs.com/weize97/p/16598216.html