zafarjonovich / yii2-telegram-bot-scelation
此包最新版本(0.0.1.5)没有提供许可证信息。
Yii2 Telegram Bot Scelation
0.0.1.5
2022-01-24 11:33 UTC
Requires
- php: >=5.6
- zafarjonovich/telegram: *
README
阿索洛穆·阿莱库姆。以下组件将帮助您在自己的项目中使用Telegram机器人API。使用起来非常简单。
安装
通过 composer 安装此扩展是首选方式。
运行以下命令:
composer require zafarjonovich/telegram
或者
"zafarjonovich/telegram": "*"
将以下内容添加到您的 composer.json
文件的 require 部分中。
使用方法
以下是如何使用 Telegram机器人API 中的所有方法的示例:
<?php require_once 'vendor/autoload.php'; $bot_token = '1111111:AAABBBBCCCDDDDEEEERRRRTTTT'; $telegram = new \zafarjonovich\Telegram\BotApi($bot_token); $telegram->query('sendMessage',[ 'chat_id' => 1122, 'text' => 'Hello world!' ]); $telegram->query('sendPhoto',[ 'chat_id' => 1122, 'photo' => 'photo_url' ]); ?>
已编写了几个Telegram方法。在机器人API方法中需要的参数在处理方法中以参数形式给出,扩展被添加到可选字段中。
编写的方法
sendMessage, deleteMessage, getChatMember, getChat, exportChatInviteLink, editMessageText, answerCallback, forwardMessage, sendPhoto, sendVideo, sendContact, sendDocument, sendLocation, getMe, getWebHookInfo, getUpdates
使用编写的方法
<?php require_once 'vendor/autoload.php'; $bot_token = '1111111:AAABBBBCCCDDDDEEEERRRRTTTT'; $telegram = new \zafarjonovich\Telegram\BotApi($bot_token); $telegram->sendMessage($chat_id,$text); $telegram->sendMessage($chat_id,$text,[ 'parse_mode' => 'markdown' ]); $telegram->sendPhoto($chat_id,$photo,[ 'caption' => 'Hello world!' ]) ?>