Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
$loader = require __DIR__.'/vendor/autoload.php';
use Longman\TelegramBot\Request;
$API_KEY = '--botfather-api-keu--';
$BOT_NAME = '--bofather-bot-name--';
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
$message = isset($argv[2]) ? $argv[2] : '';
$telegramId = isset($argv[1]) ? $argv[1] : '';
if($message !== '' && $telegramId !== ''){
$data = [];
$data['chat_id'] = $telegramId;
$data['text'] = $message;
$result = Request::sendMessage($data);
if ($result->isOk()) {
echo 'Message sent succesfully to: '.$data['chat_id'] ;
} else {
echo 'Sorry message not sent to: '.$data['chat_id'] ;
}
}
//to use it, just call: $php broadcast.php [telegram-chat-id] [message]
@ariefbayu

This comment has been minimized.

Copy link
Owner Author

@ariefbayu ariefbayu commented Feb 12, 2016

revision 2 based on the following suggestion: php-telegram-bot/core#71 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment