function doPost() { $postStr = file_get_contents("php://input"); //post data //if not encrypt Message $response = new MainResponse($postStr); $back = $response->handle(); echo $back; }
function doPost() { $postStr = file_get_contents("php://input"); //post data if (ENCRYPT_TYPE == 'ENCODING') { include dirname(__FILE__) . '/wx_encrypt.php'; $errorCode = (new WxEncrypt(TOKEN, ENCODINGAESKEY, APPID))->decrypt($_GET['msg_signature'], $_GET['timestamp'], $_GET['nonce'], $postStr, $postStr); if ($errorCode != 0) { exit($errorCode); } } $response = new MainResponse($postStr); $back = $response->handle(); if (ENCRYPT_TYPE == 'ENCODING') { $errorCode = (new WxEncrypt(TOKEN, ENCODINGAESKEY, APPID))->encrypt($back, $_GET['timestamp'], $_GET['nonce'], $back); if ($errorCode != 0) { exit($errorCode); } } echo $back; }