/** * Event tracking * * @param \TelegramBot\Api\Types\Message $message * @param string $eventName * * @throws \TelegramBot\Api\Exception * @throws \TelegramBot\Api\HttpException */ public function track(Message $message, $eventName = 'Message') { $uid = $message->getFrom()->getId(); $options = [CURLOPT_URL => self::BASE_URL . "?token={$this->token}&uid={$uid}&name={$eventName}", CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => ['Content-Type: application/json'], CURLOPT_POSTFIELDS => $message->toJson()]; curl_setopt_array($this->curl, $options); $result = BotApi::jsonValidate(curl_exec($this->curl), true); BotApi::curlValidate($this->curl); if ($result['status'] !== 'accepted') { throw new Exception('Error Processing Request'); } }