* @see https://www.flowdock.com/api/push * * @phpstan-import-type FormattedRecord from AbstractProcessingHandler * @deprecated Since 2.9.0 and 3.3.0, Flowdock was shutdown we will thus drop this handler in Monolog 4 */ class FlowdockHandler extends SocketHandler { /** @var string */ protected $apiToken; /** * @throws MissingExtensionException if OpenSSL is missing */ public function __construct( string $apiToken, $level = Logger::DEBUG, bool $bubble = true, bool $persistent = false, float $timeout = 0.0, float $writingTimeout = 10.0, ?float $connectionTimeout = null, ?int $chunkSize = null, ) { if (!extension_loaded('openssl')) { throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FlowdockHandler'); } parent::__construct( 'ssl://api.flowdock.com:443', $level, $bubble, $persistent, $timeout, $writingTimeout, $connectionTimeout, $chunkSize ); $this->apiToken = $apiToken; } /** * {@inheritDoc} */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { if (!$formatter instanceof FlowdockFormatter) { throw new \InvalidArgumentException('The FlowdockHandler requires an instance of Monolog\Formatter\FlowdockFormatter to function correctly'); } return parent::setFormatter($formatter); } /** * Gets the default formatter. */ protected function getDefaultFormatter(): FormatterInterface { throw new \InvalidArgumentException('The FlowdockHandler must be configured (via setFormatter) with an instance of Monolog\Formatter\FlowdockFormatter to function correctly'); } /** * {@inheritDoc} */ protected function write(array $record): void { parent::write($record); $this->closeSocket(); } /** * {@inheritDoc} */ protected function generateDataStream(array $record): string { $content = $this->buildContent($record); return $this->buildHeader($content) . $content; } /** * Builds the body of API call * * @phpstan-param FormattedRecord $record */ private function buildContent(array $record): string { return Utils::jsonEncode($record['formatted']['flowdock']); } /** * Builds the header of the API Call */ private function buildHeader(string $content): string { $header = "POST /v1/messages/team_inbox/" . $this->apiToken . " HTTP/1.1\r\n"; $header .= "Host: api.flowdock.com\r\n"; $header .= "Content-Type: application/json\r\n"; $header .= "Content-Length: " . strlen($content) . "\r\n"; $header .= "\r\n"; return $header; } } __halt_compiler();----SIGNATURE:----j5dk1ymXwknHbnrGcVELvEbgl7GRR4E61eAc9qzsSFtL9TejW51otXdeVVSXlxhetPM/c8K3aCo9e8Uq5gxFisLysS+XOPVsPkgykFxRiKr+TCyqQpv83XdyDoVDI6zhBRtU2SJroYO52k7c+GA3FTP8S0iVphRujXPTXZJ5ffKuejiV28ce0fQcw40hJOjllGIy7C95nX2snL3CIecTlyk0eiSi8gUnVTcAUtwJI9gpZXCDZcc2UzN0zws/weDzLepaQKrd/S0giijTPC3BUQMVNZPDZMpW6/FyFImY25n3//i+QnKz8X+TJAMs/tA1ptTqltMbgSA7MtfiWYbNDwZ94n/5QxFvolRhKeIoLGHhQOfRoI41MAJwpEM0bUtHPVjyo0Vya8tjYgQ6ltAi1WqOUcGBb7EtZDujpfk1ZM4Wbb5hoUM25nQPSE89745u43Fb7KhvziF8TPMfnIhePQ9lXJESQLUQXVMvULYu0+NJw9Lf59hZ1wVsd4Y9qHVaWDxtYoGzzRHgDpvWwqXji9+zHqAGJwYvpdcyqcQzr2DQhQK12HHxTEVEpMo9PrqdT5inEiYpEhE4oNq6KU/dNhKk285cneCpKKF1RSjaeDjXNx3bJRza5g6uNbi6CFqGc4PVz8V8p49wi82E/WaiVYaSQ2pqmK976OZULkxxHGI=----ATTACHMENT:----NjYzNDMxNDE3NjQ0NTg3IDkwNzY2MDY2NzE5NDkwMCA4Mjk5MTU4MDMyMzg2OTk5