/** * 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'); } }
/** * Use this method to send general files. On success, the sent Message is returned. * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. * * @param int $chatId * @param \CURLFile|string $document * @param int|null $replyToMessageId * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|null $replyMarkup * * @return \TelegramBot\Api\Types\Message * @throws \TelegramBot\Api\InvalidArgumentException * @throws \TelegramBot\Api\Exception */ public function sendDocument($chatId, $document, $replyToMessageId = null, $replyMarkup = null) { return Message::fromResponse($this->call('sendDocument', ['chat_id' => (int) $chatId, 'document' => $document, 'reply_to_message_id' => $replyToMessageId, 'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson()])); }
/** * Use this method to edit only the reply markup of messages sent by the bot or via the bot * * @param int|string $chatId * @param int $messageId * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|null $replyMarkup * * @return \TelegramBot\Api\Types\Message * @throws \TelegramBot\Api\InvalidArgumentException * @throws \TelegramBot\Api\Exception */ public function editMessageReplyMarkup($chatId, $messageId, $replyMarkup = null) { return Message::fromResponse($this->call('editMessageText', ['chat_id' => $chatId, 'message_id' => $messageId, 'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson()])); }