PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > 开发编程 > PHP教程 > 正文

    php 微信小程序敏感词过滤

    作者:admin来源:网络浏览:时间:2021-06-19 18:16:49我要评论
    导读:php 微信小程序敏感词过滤
    php 微信小程序敏感词过滤

    1. /** 
    2.      * 内容安全检查 
    3.      */ 
    4.     public function msgSecCheck($content){ 
    5.         $token = $this->getAccessToken(); 
    6.         $url = "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=$token"
    7.         $data='{ "content":"'.$content.'" }'
    8.         $info = $this->httpPost($url,$data); 
    9.         return json_decode($info,true); 
    10.     } 


     

    1. /** 
    2.    * http post 请求 
    3.    */ 
    4.   function httpPost($url,$data='') { 
    5.       $curl = curl_init(); 
    6.       curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
    7.       curl_setopt($curl, CURLOPT_TIMEOUT, 500); 
    8.       curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
    9.       curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
    10.       curl_setopt($curl, CURLOPT_URL, $url); 
    11.       curl_setopt($curl, CURLOPT_POST, TRUE); 
    12.       curl_setopt($curl, CURLOPT_POSTFIELDS,$data); 
    13.       $res = curl_exec($curl); 
    14.       curl_close($curl); 
    15.       return $res; 
    16.   } 

     

    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-10-6563-1.html