/** * @param AbstractMessage $message * @return string * @throws CurlException */ public function send(AbstractMessage $message) { curl_setopt($this->curlHandle, CURLOPT_POSTFIELDS, base64_encode($message->toString())); $response = curl_exec($this->curlHandle); $this->lastResponseInfo = curl_getinfo($this->curlHandle); if (false === $response) { throw new CurlException('Failed connection to ' . $this->host . ': ' . curl_error($this->curlHandle), curl_errno($this->curlHandle), null, $this->lastResponseInfo); } $statusCode = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE); if ($statusCode < 200 || $statusCode > 299) { throw new CurlException('Bad response with status code ' . $statusCode, 0, null, $this->lastResponseInfo); } return base64_decode($response); }
/** * Some kind of HBCI pagination. * * @param AbstractMessage $message * * @return array */ public function getTouchDowns(AbstractMessage $message) { $touchdown = array(); $messageSegments = $message->getEncryptedSegments(); /** @var AbstractSegment $msgSeg */ foreach ($messageSegments as $msgSeg) { $segment = $this->findSegmentForReference('HIRMS', $msgSeg); if (null != $segment) { $parts = $this->splitSegment($segment); // remove header array_shift($parts); foreach ($parts as $p) { $pSplit = $this->splitDeg($p); if ($pSplit[0] == 3040) { $td = $pSplit[3]; $touchdown[$msgSeg->getName()] = $td; } } } } return $touchdown; }
/** * @param AbstractMessage $message * @return Response * @throws AdapterException * @throws CurlException * @throws FailedRequestException */ public function sendMessage(AbstractMessage $message) { try { $this->logger->info('Sending Message'); $message->setMessageNumber($this->messageNumber); $message->setDialogId($this->dialogId); $result = $this->connection->send($message); $this->messageNumber++; $response = new Response($result); $this->handleResponse($response); if (!$response->isSuccess()) { $summary = $response->getMessageSummary(); $ex = new FailedRequestException($summary); $this->logger->error($ex->getMessage()); throw $ex; } return $response; } catch (AdapterException $e) { $this->logger->critical($e->getMessage()); if ($e instanceof CurlException) { $this->logger->debug(print_r($e->getCurlInfo(), true)); } throw $e; } }