| Recommend this page to a friend! | 
|  Download | 
| Info | Documentation |  Files |  Install with Composer |  Download | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
|     62% | Total: 1,368 This week: 1 | All time:  2,839 This week: 42  | ||||
| Version | License | PHP version | Categories | |||
| telegram-php 1.0.26 | GNU General Publi... | 5 | PHP 5, Web services, Chat | 
| Description | Author | |
| This package can send and receive messages to Telegram users. | 
Another library to use Telegram bots with PHP.
$bot = new Telegram\Bot("11111111:AAAAAAAAAAzzzzzzzzzzzzzzzzzzz", "MyUserBot", "The Name of Bot");
$tg  = new Telegram\Receiver($bot);
You can create as many Bots and Receivers or Senders as you want. Using Receiver includes a Sender.
Once the page is loaded (manually or via webhook), you can send or reply the requests.
To send a message to a user or group chat:
$tg->send
  ->chat("123456")
  ->text("Hello world!")
->send();
To reply a user command:
if($tg->text_command("start")){
  $tg->send
    ->text("Hi!")
  ->send();
}
To reply a user message:
if($tg->text_has("are you alive")){
  $tg->send
    ->text("Yes!")
  ->send();
}
NEW: To parse a string:
if($tg->text_regex("I'm {N:age}") and $tg->words() <= 4){
  $num = $tg->input->age;
  $str = "So old...";
  if($num < 18){ $str = "You're young!"; }
  $tg->send
    ->text($str)
  ->send();
}elseif($tg->text_regex("My name's {name}")){
  $tg->send
    ->text("Nice to meet you, " .$tg->input->name ."!")
  ->send();
}
Send an Inline Keyboard and parse it:
if($tg->callback == "but 1"){
  $tg->answer_if_callback(""); // Stop loading button.
  $tg->send
    ->message(TRUE)
    ->chat(TRUE)
    ->text("You pressed the first button!")
  ->edit("text");
}elseif($tg->callback == "but 2"){
  $tg->answer_if_callback("You pressed the second button!", TRUE);
  // Display an alert and stop loading button.
}
if($tg->text_has("matrix") and $tg->words() <= 5){
  $tg->send
    ->text("Red or blue. You choose.")
    ->inline_keyboard()
      ->row()
        ->button("Red",  "but 1")
        ->button("Blue", "but 2")
      ->end_row()
    ->show()
  ->send();
}
|  Files (26) | / | src | 
| File | Role | Description | ||
|---|---|---|---|---|
|  Elements (12 files) | ||||
|  Keyboards (2 files) | ||||
|  Payments (1 file) | ||||
|    Autoloader.php | Aux. | Auxiliary script | ||
|  Bot.php | Class | Class source | ||
|  Chat.php | Class | Class source | ||
|    Emojis.php | Aux. | Auxiliary script | ||
|  Message.php | Class | Class source | ||
|  Receiver.php | Class | Class source | ||
|  Sender.php | Class | Class source | ||
|  Sticker.php | Class | Class source | ||
|  User.php | Class | Class source | ||
|  Files (26) | / | src | / | Elements | 
| File | Role | Description | 
|---|---|---|
|  Audio.php | Class | Class source | 
|  Base.php | Class | Class source | 
|  ChatMember.php | Class | Class source | 
|  Document.php | Class | Class source | 
|  Location.php | Class | Class source | 
|  MessageEntity.php | Class | Class source | 
|  PhotoSize.php | Class | Class source | 
|  Sticker.php | Class | Class source | 
|  Venue.php | Class | Class source | 
|  Video.php | Class | Class source | 
|  VideoNote.php | Class | Class source | 
|  Voice.php | Class | Class source | 
|  Files (26) | / | src | / | Keyboards | 
| File | Role | Description | 
|---|---|---|
|  InlineKeyboard.php | Class | Class source | 
|  Keyboard.php | Class | Class source | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
|  Install with Composer | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
 | 
 | 
| User Ratings | ||||||||||||||||||||||||||||||
| 
 | ||||||||||||||||||||||||||||||
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.
 If you know an application of this package, send a message to the author to add a link here.