PHP code example of imafaz / neili

1. Go to this page and download the library: Download imafaz/neili 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/ */

    

imafaz / neili example snippets




use TelegramBot\Neili;

$bot = new Neili('token');

$chatId = '1826312667'; 
$message = 'hello  this message sended with neili!';
$bot->sendMessage($chatId, $message);

// $bot = new Neili(string $accessToken);

// example:

$accessToken = 'xxxxx'; 
$bot = new Neili($accessToken);

// $bot->methodName(array $parameters);

//example:

$chatId = '1826312667';
$bot->sendPhoto([
    'chat_id' => $chatId,
    'photo' => new CURLFile('test.jpg')
]);


// $bot->handleUpdate(string $secretToken = null);

// example:

// secure
$secret = 'xxxxx';
$bot->handleUpdate($secret);
// not secure
$bot->handleUpdate();

// $bot->sendMessage($chatId, $message,$keyboard,$params);

// example:

$chatId = '1826312667'; 
$message = 'hello  this message sended with neili!';

// basic
$bot->sendMessage($chatId, $message);
// advance
$bot->sendMessage($chatId, $message,null,['parse_mode'=>'html','disable_web_page_preview'=>true]);

// Neili::keyboard(array $buttons, int $raw = 2, bool $resize = true);

// example:

$buttons = ['button1','button2','button3','button4','button5'];
Neili::keyboard($buttons);

// Neili::inlineKeyboard(array $buttons, int $raw = 2);

// example:

$buttons = ['button1'=>'customdata','button2'=>'customdata','button3'=>'customdata'];
Neili::inlineKeyboard($buttons);