PHP code example of danyspin97 / php-bot-framework
1. Go to this page and download the library: Download danyspin97/php-bot-framework 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/ */
danyspin97 / php-bot-framework example snippets
// Include the framework
BotFramework\Bot("token");
// Create a command that will be triggered everytime the user send `/start`
$start_command = new PhpBotFramework\Commands\MessageCommand("start",
function($bot, $message) {
// Reply with a message
$bot->sendMessage("Hello, folks!");
}
);
$bot->addCommand($start_command);
// A shortcut for message commands.
$bot->addMessageCommand('about', function($bot, $message) {
$bot->sendMessage('Powered by PhpBotFramework');
});
// Receive updates from Telegram using getUpdates
$bot->run(GETUPDATES);
shell
export MOCK_SERVER_PORT=9696
shell
php vendor/bin/phpunit
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.