Telegram::sendMessage PHP Method

sendMessage() public method

Contacts the various API's endpoints
Values inside $content:
*
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
text String Yes Text of the message to be sent
parse_mode String Optional Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot's message. For the moment, only Telegram for Android supports this.
disable_web_page_preview Boolean Optional Disables link previews for links in this message
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendMessage ( array $content )
$content array
    public function sendMessage(array $content)
    {
        return $this->endpoint("sendMessage", $content);
    }

Usage Example

Exemplo n.º 1
0
 public function process($data)
 {
     if (isset($data['message']) && isset($data['message']['text'])) {
         switch ($data['message']['text']) {
             case '/start':
                 //выодим сообщение, что  нужно написать ключ
                 return $this->telegram->sendMessage('Введите сгенерированный код', $data['message']['chat']['id']);
                 break;
             case '/stop':
                 if ($this->deleteChatID($data['message']['chat']['id'])) {
                     return $this->telegram->sendMessage('Вы отключили функцию уведомления', $data['message']['chat']['id']);
                 }
                 break;
             case '/help':
                 return $this->telegram->sendMessage("Для подключения уведомлений введите сгенерированный код \n Для отключения уведомлений введите команду /stop ", $data['message']['chat']['id']);
                 break;
             default:
                 if ($this->alreadyConnected($data)) {
                     return false;
                 }
                 if (preg_match('#^\\d+$#', $data['message']['text'])) {
                     //число
                     return $this->connectUserByCode($data['message']['text'], $data['message']['chat']['id']);
                 } else {
                     return $this->telegram->sendMessage('not int', $data['message']['chat']['id']);
                 }
         }
     }
     return 'no_cmd';
 }
All Usage Examples Of Telegram::sendMessage