PHP code example of radyakaze / telebot

1. Go to this page and download the library: Download radyakaze/telebot library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

radyakaze / telebot example snippets



$token = 'BOT TOKEN';
$botname = 'BOT USERNAME';

ok('https://domain/path_to_hook.php');


$token = 'BOT TOKEN';
$botname = 'BOT USERNAME';

mmand : /hello => Hello world!
$tg->cmd('hello', 'Hello world!');

// Simple command with parameter : /echo telebot => telebot
$tg->cmd('echo', function($text){
  if (isset($text)) {
    return $text;
  } else {
    return '/echo <text>';
  }
 });
 
$tg->run();

$tg->cmd('upload', array(
  'type' => 'photo',
  'send' => 'path/to/photo.jpg'
);
// OR
$tg->cmd('upload2', function($text) {
  return array(
    'type' => 'photo',
    'send' => 'path/to/photo.jpg'
  )
});


$tg->cmd('myloc', function($text) {
  return array(
    'type' => 'location',
    'send' => array(-7.61, 109.51) // Gombong, Kebumen, Indonesia, you can integrate with google maps api
  )
});