/** * Parse message array from raw php input. * * @param string $content * * @throws \EasyWeChat\Core\Exceptions\RuntimeException * @throws \EasyWeChat\Encryption\EncryptionException * * @return array */ protected function parseMessageFromRequest($content) { if ($this->isSafeMode()) { if (!$this->encryptor) { throw new RuntimeException('Safe mode Encryptor is necessary.'); } $message = $this->encryptor->decryptMsg($this->request->get('msg_signature'), $this->request->get('nonce'), $this->request->get('timestamp'), $content); } else { $message = XML::parse($content); } return $message; }
/** * Parse message array from raw php input. * * @param string|resource $content * * @throws \EasyWeChat\Core\Exceptions\RuntimeException * @throws \EasyWeChat\Encryption\EncryptionException * * @return array */ protected function parseMessageFromRequest($content) { $content = strval($content); if ($this->isSafeMode()) { if (!$this->encryptor) { throw new RuntimeException('Safe mode Encryptor is necessary, please use Guard::setEncryptor(Encryptor $encryptor) set the encryptor instance.'); } $message = $this->encryptor->decryptMsg($this->request->get('msg_signature'), $this->request->get('nonce'), $this->request->get('timestamp'), $content); } else { $message = XML::parse($content); } return $message; }
/** * Parse message array from raw php input. * * @param string|resource $content * * @throws \EasyWeChat\Core\Exceptions\RuntimeException * @throws \EasyWeChat\Encryption\EncryptionException * * @return Collection */ protected function parseMessageFromRequest($content) { $content = (string) $content; $encryptor = new Encryptor($this->config->get('app_id'), $this->config->get('token'), $this->config->get('aes_key')); $message = $encryptor->decryptMsg($this->request->get('msg_signature'), $this->request->get('nonce'), $this->request->get('timestamp'), $content); return new Collection($message); }