checkSignature(); } /** * @author yj * @desc 接收微信小程序通知入口 */ public function index() { $data = file_get_contents('php://input'); $ins_data = []; $ins_data['text'] = ( $data ); $ins_data['is_success'] = 1; $ins_data['type'] = '2'; $ins_data['log'] = date('Y-m-d H:i:s'); M('log')->add($ins_data); echo 'success'; die(); } private function checkSignature() { if( isset($_GET['echostr']) ) { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = D('Home/Front')->get_config_by_name('tradecomponts_token'); $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr, SORT_STRING); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if ($tmpStr == $signature ) { echo $_GET['echostr']; die(); } else { return false; } } } }