/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($msg_signature, $timestamp, $nonce) { // $msg_signature = urldecode($msg_signature); $timestamp = urldecode($timestamp); $nonce = urldecode($nonce); $echostr = I('echostr'); $echostr = urldecode($echostr); if ($echostr) { //验证签名 if (QyHelper::isSigValid($msg_signature, $this->token, $timestamp, $nonce, $echostr)) { $prpcrypt = new Prpcrypt($this->aeskey); //解密 $content = $prpcrypt->decrypt($echostr, $this->corpid); if ($prpcrypt->isSuccess()) { Yii::$app->response->format = Response::FORMAT_RAW; \Yii::$app->response->data = $content; return \Yii::$app->response; } else { $prpcrypt->printErr(); } } else { echo '应用签名校验失败,请检查网站、token、aeskey等配置'; } } else { $msg_xml = I('xml'); if (empty($msg_xml)) { $msg_xml = file_get_contents("php://input"); } if (empty($msg_xml)) { $msg_xml = $GLOBALS["HTTP_RAW_POST_DATA"]; } $msg = QyHelper::decryptMsg($msg_xml, $this->aeskey, $this->corpid); //TODO:后续需要完善,消息接收与推送这块的功能 //这里需要能区分是哪个租户的哪个应用发来的消息 // Yii::warning('记录交互信息:'.$msg,'wx'.__LINE__); } }