微信公众平台->设置与开发->基本配置->服务器配置
public function check_wxtoken(){ $signature=trim($this->input->post_get('signature',TRUE)); $echostr=trim($this->input->post_get('echostr',TRUE)); $cData['timestamp']=trim($this->input->post_get('timestamp',TRUE)); $cData['nonce']=trim($this->input->post_get('nonce',TRUE)); $cData['token']='xxxxxx';//此处需与微信公众号后台设置内容一致 sort($cData); $tempStr=implode('',$cData); $tempStr=sha1($tempStr); if($tempStr==$signature){ echo $echostr; exit; } echo 'error'; }