zafarjonovich / telegram
此包的最新版本(2.6.3)没有提供许可证信息。
适用于所有人的Telegram助手
2.6.3
2024-04-14 12:20 UTC
Requires
- php: >=7.1
- ext-curl: *
- ext-json: *
README
阿索洛穆·阿莱库姆。这些组件将帮助您在自己的项目中使用Telegram机器人API。使用非常简单。
安装
安装此扩展的首选方式是通过composer。
运行以下命令:
composer require zafarjonovich/telegram
或者添加以下内容到您的composer.json
文件的require部分:
"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!' ]) ?>