public function isWechat() { if ($this->isRequired(['msg_signature', 'timestamp', 'nonce'], $_GET)) { extract($_GET); if (empty($_GET['echostr'])) { } else { // 第一次绑定 $echostr = urldecode($echostr); $ary = [$this->Token, $timestamp, $nonce, $echostr]; sort($ary, SORT_STRING); if ($msg_signature == sha1(implode($ary))) { die(CryptStatic::decrypt($echostr, $this->CorpID, $this->EncodingAESKey)); } } } }
/** * 对加密微信消息进行提取 * @param string $msg_crypt 待解密消息 */ protected function crypt_extract($msg_crypt) { is_object($msg_crypt) || die; return CryptStatic::decrypt($msg_crypt->Encrypt . '', $this->appid, $this->encodingAesKey); }