Last active
June 15, 2018 11:28
-
-
Save ariefbayu/e3ffe27f9c50cb674edd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
revision 2 based on the following suggestion: php-telegram-bot/core#71 (comment)